Commit d4a9839b authored by Grant's avatar Grant
Browse files

fetcher: format output & git checkout main

parent cfb2768e
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ lemmy fetcher:
    - git remote remove origin || true
    - git remote add origin https://oauth2:${GITLAB_CI_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
    - git fetch origin
    - git checkout origin main
  script:
    - python ./tools/lemmy_fetcher.py
    - tree .fetcher
+3 −3
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ def process_post(self, post_body, make_pr):
				self.send_comment(post_id, FetcherMessages.JsonError(str(ex)))
				return

		new_branch_name = "lemmy-" + str(post_id)
		new_branch_name = self.forge.mr_branch(post_id)
		if make_pr:
			# check if any content in entries is dirty
			if EDITIONS[self.edition]["entry_folder"] in subprocess.check_output(["git", "status", "--porcelain"], text=True):
@@ -211,9 +211,9 @@ def send_comment(self, post_id, comment):
		}, headers = {
			"Authorization": "Bearer " + JWT
		})
		print(req.content)
		assert req.status_code == 200
		print("Commented on post " + str(post_id))
		comment_id = req.json()["comment_view"]["comment"]["id"]
		print("Created comment https://toast.ooo/post/" + str(post_id) + "/" + str(comment_id))

	def crawl_latest(self):
		req = requests.get(ENDPOINTS["list_posts"], params={
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ def from_env(self):
		if not self.project_id:
			raise Exception("Gitlab project id is not available")
	
	def mr_branch(self, post_id: int):
		return "lemmy-" + str(post_id)

	def does_pr_already_exist(self, from_branch):
		url = "https://{}/api/v4/projects/{}/merge_requests?state=opened&source_branch={}&target_branch={}".format(self.domain, self.project_id, from_branch, "main")
		req = requests.get(url)