jj
jj copied to clipboard
`TreeDiffEntry` template method `summary()`
It is currently possible to obtain a diff summary like this, using the summary() template method of TreeDiff:
❯ jj log -r @ --no-graph --template "diff.summary()"
M docs/conflicts.md
R docs/design/{run.md => walk.md}
D docs/filesets.md
This PR adds a summary() method to TreeDiffEntry, to allow things like:
❯ target/debug/jj log -r @ --no-graph --template 'diff.files().map(|f| f.summary()).join("\n")'
docs/conflicts.md
docs/design/{run.md => walk.md}
docs/filesets.md
This template method is useful for tools like https://github.com/idursun/jjui which rely on templates to produce output. There, a template like
❯ jj log -r @ --no-graph --template 'diff.files().map(|file| separate(":",
file.status(),
file.path(),
file.summary(),
)).join("\n")'
modified:docs/conflicts.md:docs/conflicts.md
renamed:docs/design/walk.md:docs/design/{run.md => walk.md}
removed:docs/filesets.md:docs/filesets.md
could be used to obtain both the machine readable path and the { => }-style summary together.
Checklist
If applicable:
- [x] I have updated
CHANGELOG.md - [x] I have updated the documentation (
README.md,docs/,demos/) - [ ] I have updated the config schema (
cli/src/config-schema.json) - [ ] I have added/updated tests to cover my changes
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
It looks like you haven't signed the Google CLA yet. We cannot accept he PR without it.
If the goal is to get formatted (or combined) source/target path instead of source().path()/target().path() pair, it might be better to add .display_copied_path() -> String or something.
FYI, there may be some changes in this area for the new copy tracking design because the data model supports multiple files being merged into one.
Good points. I will change the name to .copied_path_summary() or similar if you want.