Skip to content

annotate: make AnnotationLine template type #5629

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

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

bryceberger
Copy link
Member

@bryceberger bryceberger commented Feb 9, 2025

Discord discussion: https://discord.com/channels/968932220549103686/1337969561793990757

Allows:

  • self.commit()
  • self.line_number()
  • self.first_line_in_hunk()

Certain pagers (like delta), when used for git blame, only show the
commit information for the first line in a hunk. This would be a nice
addition to jj file annotate.

jj file annotate already uses a template to control the rendering of
commit information --- templates.annotate_commit_summary. Instead of
a custom CLI flag, the tools necessary to do this should be available in
the template language.

If 1 % 2 or 1.is_even() was available in the template language, this
would also allow alternating colors (using raw_escape_sequence).

Example:

[templates]
# only show commit info for the first line of each hunk
annotate_commit_summary = '''
if(first_line_in_hunk,
  show_commit_info(commit),
  pad_end(20, " "),
)
'''

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

@bryceberger bryceberger force-pushed the enhance-annotate-template branch from b3a2132 to 23e1b75 Compare February 13, 2025 02:12
@bryceberger bryceberger changed the title annotate: make AnnotateData template type annotate: make AnnotationLine template type Feb 13, 2025
@martinvonz
Copy link
Member

@yuja, it looks like this is ready for another review whenever you have time. All the discussions are marked resolved but there were no text responses to any of them, so you might not have noticed.

Copy link
Contributor

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

(Please also feel free to ping me if you get no response in a couple of days.)

Allows:
* self.commit()
* self.line_number()
* self.first_line_in_hunk()

Certain pagers (like `delta`), when used for `git blame`, only show the
commit information for the first line in a hunk. This would be a nice
addition to `jj file annotate`.

`jj file annotate` already uses a template to control the rendering of
commit information --- `templates.annotate_commit_summary`. Instead of
a custom CLI flag, the tools necessary to do this should be available in
the template language.

If `1 % 2` or `1.is_even()` was available in the template language, this
would also allow alternating colors (using `raw_escape_sequence`).

Example:

```toml
[templates]
# only show commit info for the first line of each hunk
annotate_commit_summary = '''
if(first_line_in_hunk,
  show_commit_info(commit),
  pad_end(20, " "),
)
'''
```
@bryceberger bryceberger force-pushed the enhance-annotate-template branch from 23e1b75 to 8fd2dcd Compare February 15, 2025 02:17
@bryceberger bryceberger added this pull request to the merge queue Feb 15, 2025
Merged via the queue into jj-vcs:main with commit 3bc111e Feb 15, 2025
24 checks passed
@bryceberger bryceberger deleted the enhance-annotate-template branch February 15, 2025 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants