Loading .gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ lemmy fetcher: - if: $CI_PIPELINE_SOURCE == "schedule" variables: DRY_RUN: "true" FETCH_YEARS: "2024,2025,2026" before_script: - tree .fetcher - apk add git - pip install requests - git config --global user.name "Cartographer [CI]" Loading tools/lemmy_fetcher.py +5 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from entry_manager import EntryManager from lib.gitlab_forge import GitlabForge from lib.git_utils import GitUtils from lib.fetcher_messages import FetcherMessages import hashlib # cached in gitlab-ci Loading Loading @@ -157,7 +158,7 @@ def process_post(self, post_body, make_pr): return else: self.mark_post_as_failed(post_id, post_body_main_source) self.send_comment(post_id, "An error occurred while parsing this post. Maybe it’s just not a submission, but if it should, then it is not well formatted.\n\nDetailed error (note that stripping has been done on the JSON content): " + str(ex)) self.send_comment(post_id, FetcherMessages.JsonError(str(ex))) return new_branch_name = "lemmy-" + str(post_id) Loading @@ -184,15 +185,15 @@ def process_post(self, post_body, make_pr): if make_pr: if success: self.git.add(EDITIONS[self.edition]["entry_folder"]) self.git.commit("Add submission from Lemmy post " + str(post_id)) self.git.commit(FetcherMessages.git_commit(post_id)) self.git.force_push(new_branch_name) pr_url = self.forge.does_pr_already_exist(new_branch_name) if pr_url == False: print("branch pushed, making PR") pr_url = self.forge.make_pr_between_branches(new_branch_name, "main", "Add submission: " + post_body["name"], "An automated PR for submission https://toast.ooo/post/" + str(post_id)) pr_url = self.forge.make_pr_between_branches(new_branch_name, "main", FetcherMessages.git_mr_title(post_body["name"]), FetcherMessages.git_mr_description(str(post_id))) else: print("branch pushed, PR already exists") self.send_comment(post_id, "Thanks for your submission! The automatic PR has been opened at: " + pr_url) self.send_comment(post_id, FetcherMessages.SuccessfulSubmission(pr_url)) else: self.git.restore(EDITIONS[self.edition]["entry_folder"]) self.git.checkout("main") Loading tools/lib/fetcher_messages.py 0 → 100644 +19 −0 Original line number Diff line number Diff line class FetcherMessages(): def JsonError(ex: str): return """An error occurred while parsing this post. If this isn't an Atlas submission, you can ignore this comment. Exception details: {} """.format(ex) def SuccessfulSubmission(mr_url: str): return """Thanks for your submission! I've created an MR for you: {}""".format(mr_url) def git_commit(post_id: int): return "Add submission (https://toast.ooo/post/{})".format(str(post_id)) def git_mr_title(post_name: str): return "Add submission: " + post_name def git_mr_description(post_id: int): return "An automated MR for submission https://toast.ooo/post/{}".format(str(post_id)) No newline at end of file Loading
.gitlab-ci.yml +2 −0 Original line number Diff line number Diff line Loading @@ -36,7 +36,9 @@ lemmy fetcher: - if: $CI_PIPELINE_SOURCE == "schedule" variables: DRY_RUN: "true" FETCH_YEARS: "2024,2025,2026" before_script: - tree .fetcher - apk add git - pip install requests - git config --global user.name "Cartographer [CI]" Loading
tools/lemmy_fetcher.py +5 −4 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ from entry_manager import EntryManager from lib.gitlab_forge import GitlabForge from lib.git_utils import GitUtils from lib.fetcher_messages import FetcherMessages import hashlib # cached in gitlab-ci Loading Loading @@ -157,7 +158,7 @@ def process_post(self, post_body, make_pr): return else: self.mark_post_as_failed(post_id, post_body_main_source) self.send_comment(post_id, "An error occurred while parsing this post. Maybe it’s just not a submission, but if it should, then it is not well formatted.\n\nDetailed error (note that stripping has been done on the JSON content): " + str(ex)) self.send_comment(post_id, FetcherMessages.JsonError(str(ex))) return new_branch_name = "lemmy-" + str(post_id) Loading @@ -184,15 +185,15 @@ def process_post(self, post_body, make_pr): if make_pr: if success: self.git.add(EDITIONS[self.edition]["entry_folder"]) self.git.commit("Add submission from Lemmy post " + str(post_id)) self.git.commit(FetcherMessages.git_commit(post_id)) self.git.force_push(new_branch_name) pr_url = self.forge.does_pr_already_exist(new_branch_name) if pr_url == False: print("branch pushed, making PR") pr_url = self.forge.make_pr_between_branches(new_branch_name, "main", "Add submission: " + post_body["name"], "An automated PR for submission https://toast.ooo/post/" + str(post_id)) pr_url = self.forge.make_pr_between_branches(new_branch_name, "main", FetcherMessages.git_mr_title(post_body["name"]), FetcherMessages.git_mr_description(str(post_id))) else: print("branch pushed, PR already exists") self.send_comment(post_id, "Thanks for your submission! The automatic PR has been opened at: " + pr_url) self.send_comment(post_id, FetcherMessages.SuccessfulSubmission(pr_url)) else: self.git.restore(EDITIONS[self.edition]["entry_folder"]) self.git.checkout("main") Loading
tools/lib/fetcher_messages.py 0 → 100644 +19 −0 Original line number Diff line number Diff line class FetcherMessages(): def JsonError(ex: str): return """An error occurred while parsing this post. If this isn't an Atlas submission, you can ignore this comment. Exception details: {} """.format(ex) def SuccessfulSubmission(mr_url: str): return """Thanks for your submission! I've created an MR for you: {}""".format(mr_url) def git_commit(post_id: int): return "Add submission (https://toast.ooo/post/{})".format(str(post_id)) def git_mr_title(post_name: str): return "Add submission: " + post_name def git_mr_description(post_id: int): return "An automated MR for submission https://toast.ooo/post/{}".format(str(post_id)) No newline at end of file