-
Notifications
You must be signed in to change notification settings - Fork 382
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
cli: add template-aliases.'should_sign_off()'
to configure sign offs
#5290
base: main
Are you sure you want to change the base?
Conversation
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'm not sure if I like this pattern to be supported formally. It looks like a bit of hack. Another option is to add config(name).to_<type>()
function, but they are technically not so different in that random global data is referred to.
cli/src/config/templates.toml
Outdated
@@ -32,6 +32,10 @@ if(overridden, | |||
draft_commit_description = ''' | |||
concat( | |||
description, | |||
if( | |||
should_sign_off() && !description.contains("Signed-off-by: " ++ author.name()), | |||
"\nSigned-off-by: " ++ author.name() ++ " <" ++ author.email() ++ ">", |
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.
nits:
- missing newline?
- just
author
should work (name <email>
is the default output) - maybe it should be
committer
?
cli/src/config/templates.toml
Outdated
@@ -32,6 +32,10 @@ if(overridden, | |||
draft_commit_description = ''' | |||
concat( | |||
description, | |||
if( | |||
should_sign_off() && !description.contains("Signed-off-by: " ++ author.name()), |
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: probably better to pass self
explicitly to should_sign_off(self)
Yes, I wanted some opinions on what people thought of this, and it was only like 5 lines, so I figured submitting a patch would be the best way to kick things off. :) /cc @martinvonz @ilyagr @arxanas One reason I was thinking about this is because I used it to add |
I also admit I don't like using |
Don't we already support several formal pieces of global data/configuration? Namely
As an alternative level of abstraction, we could use "trailers" (as per Git), and have some kind of
To handle this workflow:
|
Yes. They're technically the same. I just had a feeling that using aliases as boolean flags is a bit hackish. To be clear, I'm not against this PR nor adding |
|
Many of the desired features for the default commit template, notably pre-populating things, can be solved with a simple pattern: 1. Inside `template-aliases.draft_commit_message`, use the following: if(config("name.space").as_boolean() && !description.contains("..."), ...)` 2. Set `name.space = true` in repos where you want it enabled. This patch uses this idea to configure a new behavior to get `Signed-off-by` lines included in their repositories. While `Signed-off-by:` is a git mechanism, it is a common one and this makes it easier to use jj OOTB with repositories that might require those, without adding any more real surface area to the Rust codebase. This general idea can be configured by the user though, e.g. for `BUG=123` templates, or Gerrit `Change-Id`s, or other various things. Signed-off-by: Austin Seipp <[email protected]>
2dcf66e
to
04630c5
Compare
Many of the desired features of the default commit template can be solved with a simple pattern:
Write a
template-aliases
functionshould_do_something() = 'false'
to your global configInside
template-aliases.draft_commit_message
, use the following:Set
should_do_something() = 'true'
in repos where you want it enabled.This patch uses this idea to configure a new, built-in
signed_off_by()
template alias, which defaults tofalse
. With this, a user only has to configure this totrue
in order to getSigned-off-by
lines included in their repositories.While
Signed-off-by:
is a git mechanism, it is a common one and this makes it easier to use jj OOTB with repositories that might require those, without adding any more real surface area to the Rust codebase. This general idea can be configured by the user though, e.g. forBUG=123
templates, or GerritChange-Id
s, or other various things.Checklist
If applicable:
CHANGELOG.md