Closed tobiasdiez closed 3 years ago
This looks nice. I'll see if I can get my staging instance of trac.sagemath.org up-and-running again and test it.
There used to be a repo...I thought it was on GitHub...where I documented a lot of this stuff. I wonder what happened to it. I can't find it anymore (and it needs to be updated a bit probably).
I found it--for some reason it's under William Stein's account, I guess because he had some allowance for private repos. We should probably move it. Also I don't think there's any information that needs to be kept strictly private, though we can leave it private now.
I had to make the following additional changes for it to work. The problem is the local variable branch
was later being replaced from the branch name to a pygit Commit object. I changed it to use a new variable for that purpose:
diff --git a/sage_trac/ticket_box.py b/sage_trac/ticket_box.py
index 0f35c9b..ebaf572 100644
--- a/sage_trac/ticket_box.py
+++ b/sage_trac/ticket_box.py
@@ -135,11 +135,11 @@ class TicketBox(git_merger.GitMerger):
if url is not None:
links.append(tag.a('Commits', href=url))
links.append(tag.span(', '))
- github_url = f"https://github.com/sagemath/sagetrac-mirror/compare/develop...{branch}"
- gitlab_url = f"https://gitlab.com/sagemath/dev/tracmirror/-/compare/develop...{branch}"
- links.append(tag.a('GitHub', href=github_url))
+ github_url = "https://github.com/sagemath/sagetrac-mirror/compare/develop...{branch}"
+ gitlab_url = "https://gitlab.com/sagemath/dev/tracmirror/-/compare/develop...{branch}"
+ links.append(tag.a('GitHub', href=github_url.format(branch=branch)))
links.append(tag.span(', '))
- links.append(tag.a('GitLab', href=gitlab_url))
+ links.append(tag.a('GitLab', href=gitlab_url.format(branch=branch)))
links.append(tag.span(')'))
return FILTER_BRANCH.append(links)
@@ -158,10 +158,10 @@ class TicketBox(git_merger.GitMerger):
base_branch = None
try:
- is_sha, branch = self.generic_lookup(branch)
+ is_sha, branch_commit = self.generic_lookup(branch)
if is_sha:
filters.append(
- FILTER_BRANCH_TEXT.replace(branch.hex[:7]+' '))
+ FILTER_BRANCH_TEXT.replace(branch_commit.hex[:7]+' '))
if base_branch:
_, base_branch_commit = self.generic_lookup(base_branch)
@@ -173,8 +173,8 @@ class TicketBox(git_merger.GitMerger):
else:
return error("sha1 hash is too ambiguous")
- ret = self.peek_merge(branch, base_branch=base_branch)
- _, log_url = self.get_merge_url(req, branch, ret,
+ ret = self.peek_merge(branch_commit, base_branch=base_branch)
+ _, log_url = self.get_merge_url(req, branch_commit, ret,
base=base_branch_commit)
# For the merge-url just always pass through the git-merger frontend
@@ -183,7 +183,7 @@ class TicketBox(git_merger.GitMerger):
params.append(('base', base_branch))
if branch:
- git_merger_url = req.abs_href('/git-merger/' + branch.hex, params)
+ git_merger_url = req.abs_href('/git-merger/' + branch_commit.hex, params)
else:
git_merger_url = None
Ok thanks!
Any news on bringing this live?
Bump!
I added this manually along with a few additional minor changes in f19f3ba. Thanks!
Add links to the github and gitlab mirrors in the ticket description, since both have a visual appealing interface and are able to show the content of the branch even with merge conflicts. It should look as follows:
(Again with the caveat that I don't know how to test the code...)