Skip to content

cli: Add git fetch template - #10084

Open
bobrippling wants to merge 2 commits into
jj-vcs:mainfrom
bobrippling:feat/9311-fetch-template
Open

cli: Add git fetch template#10084
bobrippling wants to merge 2 commits into
jj-vcs:mainfrom
bobrippling:feat/9311-fetch-template

Conversation

@bobrippling

Copy link
Copy Markdown
Contributor

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/updated tests to cover my changes
  • I fully understand the code that I am submitting (what it does,
    how it works, how it's organized), including any code drafted by an LLM.
  • For any prose generated by an LLM, I have proof-read and copy-edited with
    an eye towards deleting anything that is irrelevant, clarifying anything
    that is confusing, and adding details that are relevant. This includes,
    for example, commit descriptions, PR descriptions, and code comments.

@bobrippling
bobrippling force-pushed the feat/9311-fetch-template branch from 03dbe5b to ec6f78d Compare August 30, 2026 15:44
@bobrippling

bobrippling commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure what's going on with the rustfmt check, it seems to be flagging a very large number of files

fmt problem is fixed in #10081

@bobrippling
bobrippling marked this pull request as ready for review August 30, 2026 16:17
@bobrippling
bobrippling requested a review from a team as a code owner August 30, 2026 16:17
@bobrippling
bobrippling force-pushed the feat/9311-fetch-template branch from ec6f78d to 148dcae Compare August 30, 2026 18:03
Comment thread cli/src/commit_templater.rs

@josephlou5 josephlou5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you need to update docs/templates.md.

Comment thread cli/src/commands/git/fetch.rs
Comment thread cli/src/config/templates.toml Outdated
Comment thread cli/src/commit_templater.rs
Comment thread cli/src/config/templates.toml Outdated
Comment thread cli/tests/test_git_fetch.rs
`jj git fetch` output can now be templated (`-T`), rather than the
previous `RefStatus::output()`. Each ref is exposed as a `RefStatus`
type.

`RefStatus` has the usual methods, along with `max_name_width` (width of
the longest name in a group - bookmarks/tags), so columns can be
aligned.

A `templates.git_fetch` template has been added, which preserves the
original aligned format.

Closes jj-vcs#9311
@bobrippling
bobrippling force-pushed the feat/9311-fetch-template branch from 148dcae to a99e3bb Compare August 31, 2026 08:48
/// https://docs.jj-vcs.dev/latest/templates/
#[arg(long, short = 'T')]
#[arg(add = ArgValueCandidates::new(complete::template_aliases))]
template: Option<String>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use --config instead? Other commands don't use -T/--template when rendering a template is their primary purpose.

Comment thread cli/src/cli_util.rs
pub fn commit_fetch_template(
&self,
template: Option<&str>,
) -> TemplateRenderer<'_, crate::git_util::RefStatus> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Maybe move to git_util? I don't think we need a global helper.

build(self, diagnostics, build_ctx, property, function)
}
#[cfg(feature = "git")]
CommitTemplatePropertyKind::RefStatus(property) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we introduce a generic diff type for CommitRef or RemoteRef? It should probably support both fetch and push summaries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To check I understand, are you saying we want to change RefStatus to something like RefDiff so it'll work with a template for jj git push ?

Comment thread docs/templates.md
type](#operation-type) are available as keywords. For example,
`current_operation` is equivalent to `self.current_operation()`.

### RefStatus keywords

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This section is unnecessary I think.

Comment thread docs/templates.md
* `.import_status() -> String`: "new" if the ref has just been fetched,
"deleted" if it's just been deleted, or "updated" for changed refs.
* `.kind() -> String`: "bookmark" or "tag".
* `.max_name_width() -> Integer`: the length of the longest `name` in the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please make it clearer that a different value is returned for bookmarks than for tags, and that it only applies to the current jj git fetch command.

Comment thread docs/templates.md

The following methods are defined.

* `.name() -> String`: bookmark or tag name.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please capitalize these sentences if they're not quoted values ("bookmark" → "Bookmark", "the length" → "The length").

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