-
Notifications
You must be signed in to change notification settings - Fork 14
jj: label single-change diffs with the description #250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -563,6 +563,72 @@ function JjAdapter:parse_revs(rev_arg, opt) | |
| return left, right | ||
| end | ||
|
|
||
| ---@param left Rev | ||
| ---@param right Rev | ||
| ---@return string|nil | ||
| function JjAdapter:single_change_subject(left, right) | ||
| if not (left and left.commit and right) then | ||
| return | ||
| end | ||
|
|
||
| if left.commit == JjRev.NULL_TREE_SHA then | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This drops the initial commit description. Is this intentional? |
||
| return | ||
| end | ||
|
|
||
| local right_rev | ||
| if right.type == RevType.LOCAL then | ||
| right_rev = "@" | ||
| elseif right.commit and right.commit ~= JjRev.NULL_TREE_SHA then | ||
| right_rev = right.commit | ||
| else | ||
| return | ||
| end | ||
|
|
||
| local out, code = self:exec_sync( | ||
| utils.vec_join( | ||
| self:args(), | ||
| "--ignore-working-copy", | ||
| "log", | ||
| "--no-graph", | ||
| "-r", | ||
| right_rev, | ||
| "-T", | ||
| [[parents.first().commit_id() ++ "\x1f" ++ description.first_line() ++ "\n"]] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems fragile. It's depending the literal string |
||
| ), | ||
| { | ||
| cwd = self.ctx.toplevel, | ||
| retry = 2, | ||
| silent = true, | ||
| log_opt = { label = "JjAdapter:single_change_subject()" }, | ||
| } | ||
| ) | ||
|
|
||
| if code ~= 0 or not out[1] then | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't |
||
| return | ||
| end | ||
|
|
||
| local parent, subject = vim.trim(out[1]):match("^([^\31]*)\31(.*)$") | ||
| if parent ~= left.commit then | ||
| return | ||
| end | ||
|
|
||
| subject = vim.trim(subject or "") | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return subject ~= "" and subject or nil | ||
| end | ||
|
|
||
| ---@param rev_arg string? | ||
| ---@param left Rev | ||
| ---@param right Rev | ||
| ---@return string|nil | ||
| function JjAdapter:rev_to_panel_name(rev_arg, left, right) | ||
| local subject = self:single_change_subject(left, right) | ||
| if subject then | ||
| return subject | ||
| end | ||
|
|
||
| return rev_arg or self:rev_to_pretty_string(left, right) | ||
| end | ||
|
|
||
| ---@param rev_arg string? | ||
| ---@param left Rev | ||
| ---@param right Rev | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have backticks around
rev_to_pretty_stringandrev_arg.