You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to see in the commit log which commits have a bookmark associated to a Github PR, and is that PR up to date.
Right now, I have to do jj log to read the branch name, then go to the Github PR page in my browser
and list the PRs, then carefully read the list and match the names to PR numbers in my head.
This could be automated. I use JJ to manage my local commit history, and then create stacks of PRs in github. I often need to ping team members about reviewing these PRs. Using jj log I can easily see the stack of PRs in the correct order.
Describe the solution you'd like jj log should print the Github PR number (or any other forge) in the log summary line.
GIVEN
A local JJ repo with Github as the remote origin
The JJ repo has bookmarks associated Git branches in the origin repo
The Github repo has PRs associated with those branches
WHEN the user runs jj log
THEN jj will match the git commit and bookmarks for a commit to the appropriate remote refs from the Github origin repo.
I created a prototype python script to demonstrate the logic (see attached). Here is the output:
$~/p/c/jj-java-connector jj log-pr 10:42:55
○ sxptnunm [email protected] 2025-01-23 09:40:24 gh-2043-update-on-dns-change* 10dde303 #2056 (out of date)
│ feat: Automatically reset DNS-configured connections on DNS change
@ kqzvmskn [email protected] 2025-01-23 09:40:24 gh-2043-configure-with-dns* 3cd89b15 #2047
│ feat: Automatically configure connections using DNS. Part of #2043.
○ yxzqswyk [email protected] 2025-01-17 11:58:36 gh-2043-use-r2dbc-host c389387c #2103
│ chore: Use domain name from R2DBC connections when configuring the connector.
Describe alternatives you've considered
The full Github Integration sounds like it could work (See #4555). But this is a much larger scope. Also, I just want to see the Github PRs in the jj log output without requiring that I use Github and JJ in an opinionated way.
I created a jj utility in Python to do this, but it is brittle because it depends on the output format of jj log.
Additional context
I wrote a prototype python script to demonstrate the logic. This can be done entirely with git ls remote. There is
no need to call the Github API.
#!/usr/bin/env python3importsubprocessimportosimportredefremove_color_codes(text):
"""Removes terminal color escape codes from a string. Args: text: The string containing color escape codes. Returns: The string with color escape codes removed. """# Regular expression to match ANSI escape codesansi_escape=re.compile(r'\x1b\[[0-9;]*[mG]')
returnansi_escape.sub('', text)
defgit_ls_remote_prs():
""" Lists remote refs for PRs :return: dict[ commit_id | branch_name ] = pr_number """my_env=os.environ.copy()
my_env['GIT_DIR'] =".jj/repo/store/git"proc_git=subprocess.Popen(
['git', 'ls-remote', 'origin', 'pull/*', 'heads/*'],
stdout=subprocess.PIPE,
env=my_env)
branches= {}
git_prs= {}
lines=proc_git.stdout.readlines()
forlineinlines:
(commit_id, pr_ref) =line.decode().strip().split("\t")
ref_parts=pr_ref.split('/')
ifref_parts[1] =="pull":
git_prs[commit_id[0:8]] =ref_parts[-2]
ifref_parts[1] =="heads":
branches[ref_parts[2]] =commit_id[0:8]
proc_git.wait()
forbranch, cidinbranches.items():
ifcidingit_prs:
git_prs[branch] =git_prs[cid]
returngit_prsdefjj_log(git_prs):
my_env=os.environ.copy()
proc_jj_log=subprocess.Popen(
['jj', 'log', '--color=always'],
stdout=subprocess.PIPE,
env=my_env)
clean_branch_name=re.compile(r'\*$')
lines=proc_jj_log.stdout.readlines()
forlineinlines:
line=line.decode().strip()
txt_line=remove_color_codes(line)
# Split the string by spacesline_parts=txt_line.split()
# Get the last two elements of the split stringiflen(line_parts) >=2:
bookmark=line_parts[-2]
bookmark=clean_branch_name.sub("",bookmark)
commit_id=line_parts[-1]
ifcommit_idingit_prs:
print(line, "#%s"%git_prs[commit_id])
elifbookmarkingit_prs:
print(line, "\033[91m#%s (out of date)\033[0m"%git_prs[bookmark])
else:
print(line)
proc_jj_log.wait()
if__name__=='__main__':
prs=git_ls_remote_prs()
jj_log(prs)
The text was updated successfully, but these errors were encountered:
I created a jj utility in Python to do this, but it is brittle because it depends on the output format of jj log.
You can make your script less brittle and probably simpler by supplying an explicit template to jj log. (see the docs for the templating language) The flag jj log --no-graph may also be useful.
Is your feature request related to a problem? Please describe.
I want to see in the commit log which commits have a bookmark associated to a Github PR, and is that PR up to date.
Right now, I have to do
jj log
to read the branch name, then go to the Github PR page in my browserand list the PRs, then carefully read the list and match the names to PR numbers in my head.
This could be automated. I use JJ to manage my local commit history, and then create stacks of PRs in github. I often need to ping team members about reviewing these PRs. Using
jj log
I can easily see the stack of PRs in the correct order.Describe the solution you'd like
jj log
should print the Github PR number (or any other forge) in the log summary line.GIVEN
WHEN the user runs
jj log
THEN jj will match the git commit and bookmarks for a commit to the appropriate remote refs from the Github origin repo.
I created a prototype python script to demonstrate the logic (see attached). Here is the output:
Describe alternatives you've considered
The full Github Integration sounds like it could work (See #4555). But this is a much larger scope. Also, I just want to see the Github PRs in the
jj log
output without requiring that I use Github and JJ in an opinionated way.I created a jj utility in Python to do this, but it is brittle because it depends on the output format of
jj log
.Additional context
I wrote a prototype python script to demonstrate the logic. This can be done entirely with
git ls remote
. There isno need to call the Github API.
The text was updated successfully, but these errors were encountered: