Skip to content
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

describe: add ignore-rest directive #5155

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

bryceberger
Copy link
Contributor

@bryceberger bryceberger commented Dec 20, 2024

Implements #4210

Instead of a scissor line, this implements a scissor section. Everything between a pair of scissor lines is ignored. This allows it to work with #3828, as long as you put the ending line. Currently the beginning and ending lines are the same, so only one alias is required. Could easily be separated.

Implements a single scissor line, since JJ: describe lines are parsed first. Everything after a scissor line, before a JJ: describe line is ignored.

Open to other ideas on the style of the scissor lines. Additionally, the scissor template alias does not insert the "Do not modify or remove the line above." line from git --- should it? I lean softly towards no, since the user would have to seek out the alias to end up with it.

Example usage

[templates]
draft_commit_description = '''
concat(
  description,
  "\nJJ: ignore-rest\n",
  diff.git(),
)
'''

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have added tests to cover my changes

@bryceberger
Copy link
Contributor Author

Updated the jjdescription tree-sitter grammar at kareigu/tree-sitter-jjdescription#2.

todo: tests, docs

@yuja
Copy link
Contributor

yuja commented Dec 20, 2024

Instead of a scissor line, this implements a scissor section. Everything between a pair of scissor lines is ignored. This allows it to work with #3828

Just fyi, #3828 should be compatible with scissors. The "JJ: describe " line should be parsed first.

(BTW, we tend to include details in commit messages than in PR description.)

@bryceberger
Copy link
Contributor Author

Just fyi, #3828 should be compatible with scissors. The "JJ: describe " line should be parsed first.

Oh, didn't notice that. Updated to only require one line.

@bryceberger
Copy link
Contributor Author

Paging @ilyagr and @arxanas, as you both had comments about the design of a scissor line in #4210

@martinvonz
Copy link
Member

I think @arxanas had a good point about discoverability. Something like "JJ: ignore-after" or "JJ: ignore-rest" is a lot clearer and more searchable.

@bryceberger
Copy link
Contributor Author

bryceberger commented Dec 23, 2024

Changed to JJ: ignore-rest, and removed builtin alias as it's easy to type. Slightly less visible, but if the user wants to have a more visible marker they can easily insert it in their default template.

I do have a concern about docs. There didn't seem to be a good place to put it, so right now it's only mentioned in the changelog and "default description" config. If we keep adding similar directives (JJ: describe ..., JJ: ignore-rest, ..?), there should probably be a dedicated spot for them.

@bryceberger bryceberger requested a review from yuja December 23, 2024 02:11
@bryceberger
Copy link
Contributor Author

Just found the line in the default config referencing #1946, which this also provides the ability to solve.

@bryceberger bryceberger changed the title describe: add a "scissor line" describe: add ignore-rest directive Dec 23, 2024
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!

cli/src/description_util.rs Outdated Show resolved Hide resolved
cli/tests/test_describe_command.rs Outdated Show resolved Hide resolved
This implements "scissor" lines. For example:

    this text is included in the commit message
    JJ: ignore-rest
    this text is not, and is encouraged to be rendered as a diff
    JJ: ignore-rest
    this text is *still not* included in the commit message

When editing multiple commit messages, the `JJ: describe {}` lines
are parsed before the description is cleaned up. That means that the
following will correctly add descriptions to multiple commits:

    JJ: describe aaaaaaaaaaaa
    this text is included in the first commit message
    JJ: ignore-rest
    scissored...
    
    JJ: describe bbbbbbbbbbbb
    this text is included in the first commit message
    JJ: ignore-rest
    scissored...
@bryceberger bryceberger enabled auto-merge (rebase) December 23, 2024 23:22
@bryceberger bryceberger merged commit 1d3c3b8 into jj-vcs:main Dec 23, 2024
18 checks passed
@bryceberger bryceberger deleted the describe-scissors branch December 23, 2024 23:33
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