-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Add support for ${author} and ${branch} in templates #792
base: master
Are you sure you want to change the base?
Add support for ${author} and ${branch} in templates #792
Conversation
@@ -277,7 +277,17 @@ CommitEditor::CommitEditor(const git::Repository &repo, QWidget *parent) | |||
} | |||
} | |||
} | |||
applyTemplate(t, files); | |||
|
|||
RepoView *view = RepoView::parentView(this); |
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 was not sure if there was an easier way to get the author and branch name at this point
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.
Good question. Because of the possibility to temporarly changing the username amd email, I think you need to take the one from the repoview
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.
When you change temporarly the username (click on the Author
link above the commit message), still the old name is used.
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.
@esteban-aliverti can you have a look into it?
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.
QString pattern = TemplateButton::filesPosition; | ||
pattern.replace("{", "\\{"); | ||
pattern.replace("}", "\\}"); | ||
pattern.replace("$", "\\$"); | ||
QRegularExpression re(pattern); | ||
QRegularExpressionMatch match = re.match(templ); | ||
int start = -1; |
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 didn't understand why were we calculating the offset instead of simply replacing all the variables and then checking where the placeholder for the cursor was left after all the substitutions.
This is what I'm doing not, but I may have missed something.
This PR adds basic support for
${author}
and${branch}
variables in the commit templates.It is also possible to use a part of the branch name by adding a regular expression to the
${branch}
variable. For example:${branch:ISSUE-[0-9]+}
. In this case, if the branch name is something like "bugfix/ISSUE-1234_something", the value of the variable will be "ISSUE-1234"This is related to issue #457