-
Notifications
You must be signed in to change notification settings - Fork 832
templates: Expose copy/move path formatting and status char #8184
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
base: main
Are you sure you want to change the base?
Conversation
14ad12b to
51ac932
Compare
yuja
left a comment
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.
Thanks.
| }, | ||
| ); | ||
| map.insert( | ||
| "formatted_path", |
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.
nit: since this only matters for copied entries, I think the function name should include "copy", e.g. display_copied_path(). Maybe we could add copied_path() -> CopiedTreeDiffEntryPath function, but I don't think we'll add functions other than copied_path().display().
Another option is to add path.display_copy_from(source.path()) function to RepoPath template type.
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.
In my head this is not a copy specific function. It only makes a difference for copies, but it has the behavior you would want in general. Still open yo name changed, but I would prefer something that doesn't suggest it's copy specific.
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.
I mean path().display() vs formatted_path() matters only when the entry was copied/renamed. It may be confusing if we have two ways of formatting paths.
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.
Ideally path().display() should take the move into account so that we only have one way of doing formatting. I guess that would involve making path() return some new type.
It would be a mildly breaking change, but code relying on the old behavior can easily migrate to use (the much more explicit) target().
| }); | ||
| Ok(out_property.into_dyn_wrapped()) | ||
| }, | ||
| ); |
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.
It's probably better to rebase this on top of #8123.
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.
The relevant code is now in main
| concat( | ||
| description.first_line() ++ ":\n", | ||
| diff.files().map(|e| | ||
| e.status_char() ++ " " ++ e.path() ++ "\n" |
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.
nit: can you instead update existing tests to minimize test execution time? I think there are tests for .status() in test_commit_template.rs or test_diff_command.rs.
This allows replicating the default diff summary display in templates.
This will go well with #8183 for custom log templates. E.g. with
you can create a log template looking something like
Checklist
If applicable:
CHANGELOG.mdREADME.md,docs/,demos/)cli/src/config-schema.json)