Open adrianrivers opened 1 year ago
hi hi
would be cool to have this configurable via oc config set branch=true
or if you have a better name — do it :)
I just came to ask the same question, it would be great a feature like this, for now without this configuration I can't use oc. Is there any way to get the output of the commit with a command? For example, to do my own command setup, I have an alias as a function that does this job of getting the ticket name automatically for me. For example:
# Commit everything
function commit() {
commitMessage="$1"
if [ "$commitMessage" = "" ]; then
commitMessage="wip"
fi
# check if getIssueName returns a value and if it does, then prepend it to the commit message
if [ -n "$(getIssueName)" ]; then
commitMessage="$(getIssueName): $commitMessage"
fi
git add .
git status
eval "git commit -a -m \"${commitMessage}\" $2"
}
I have another function getIssueName
that extracts the ticket name depending on my branch name.
Taking the example of @adrianrivers feat/foo-1234-button
the function getIssueName
would extract foo-1234
and put it at the beginning of the commit, so when doing
commit "Changes in the user module"
The final message would be: foo-1234: Changes in the user module
.
Now, if there was a way to extract the output suggested by opencommit, a function like this could be done automatically.
# Commit everything
function commit() {
commitMessage="$1"
if [ "$commitMessage" = "" ]; then
commitMessage="wip"
fi
generatedMessage="oc --raw" #or sometinhg like that
# check if getIssueName returns a value and if it does, then prepend it to the commit message
if [ -n "$(getIssueName)" ]; then
commitMessage="$(getIssueName): $generatedMessage"
fi
git add .
git status
eval "git commit -a -m \"${commitMessage}\" $2"
}
I would like to have config options like below:
oc config set prefix="xxx"
oc config set suffix="xxx"
I believe oc config set scope=true
which automatically extracts ticket number and pastes as a prefix is best UX. WDYT?
anybody wants to make a PR?
I believe oc config set scope=true which automatically extracts ticket number and pastes as a prefix is best UX. WDYT?
It would be great, but I think it would be very difficult to create a regex to identify the ticket of each one, since it could be anything, don't you think?
Stale issue message
Hi, I'm happy to contribute to this. My work requires that the ticket be referenced in all commit messages e.g.
foo-1243-feature-button-component
. I'm wondering if it is viable to make the commits reference the ticket number from the branch name e.g.feat/foo-1234-button
would result in commit messages being prefixed withfoo-1234: blah blah
?