Skip to content

Conversation

@tardypad
Copy link
Contributor

@tardypad tardypad commented Oct 6, 2016

Continuing the moving of some of my local git aliases and functions
in order to make them more maintainable and so that other people can use them too 😁

This adds a new stamp command: Stamp the last commit message
See the manual for the use cases and examples

The command is best used afterwards with personal aliases such as issue = stamp -r Issue
The usage is then git issue FOO-142 to stamp the commit with an issue number

issue BAR-123
```


Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion, it will be greater if you also show the change of last commit via git log in this introduction.

Copy link
Contributor Author

@tardypad tardypad Oct 7, 2016

Choose a reason for hiding this comment

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

You mean showing the exact result of the commands as it they were executed?
Meaning with the commit hash, author name and date as well

Copy link
Collaborator

@spacewander spacewander Oct 7, 2016

Choose a reason for hiding this comment

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

Yes.

bin/git-stamp Outdated

error() {
if [[ -n "$1" ]]; then
local msg=$( echo "error: $1" | sed 's/\\n/\\n /g' )
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the reason to add some trailing whitespace after error message?

Copy link
Contributor Author

@tardypad tardypad Oct 7, 2016

Choose a reason for hiding this comment

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

Ah that a copy paste from my previous git reauthor command
https://github.com/tardypad/git-extras/blob/stamp/bin/git-reauthor#L32
This was for multiple lines error message so that the second line is aligned with the : as in

error: missing target of the rewrite
       use either --old-email option or --all flag

It's not needed here, I better remove it then I guess

echo "${commit_msg}" \
| grep --ignore-case --invert-match "^${ID}\b" \
| cat --squeeze-blank
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is a corner case:
What will happen if commit message without stamp shares same prefix with $ID?
For example, run git stamp 'stamp:' blahblah on your branch.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this case is unavoidable... Warn it in the document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed this is "unavoidable" the way it is
That's why I show the new commit message as a result, so that people can check that nothing went wrong.
But it's better to be explicit and I'll put a warning in the documentation

_git_stamp(){
__gitcomp '--replace -r'
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I notice that you have updated the bash completion script. It will be great if you also update the zsh one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright I'll try to add it since that should be a simple one
I am not sure I'll be able to test it though
Configuring and switching to ZSH is still on my TODO list :)

Copy link
Collaborator

@spacewander spacewander left a comment

Choose a reason for hiding this comment

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

That is all, my review is finished.

Copy link
Contributor Author

@tardypad tardypad left a comment

Choose a reason for hiding this comment

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

Thanks

Just waiting for your confirmation about the meaning of your comment about the Commands.md file
and then I'll implement the changes

issue BAR-123
```


Copy link
Contributor Author

@tardypad tardypad Oct 7, 2016

Choose a reason for hiding this comment

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

You mean showing the exact result of the commands as it they were executed?
Meaning with the commit hash, author name and date as well

bin/git-stamp Outdated

error() {
if [[ -n "$1" ]]; then
local msg=$( echo "error: $1" | sed 's/\\n/\\n /g' )
Copy link
Contributor Author

@tardypad tardypad Oct 7, 2016

Choose a reason for hiding this comment

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

Ah that a copy paste from my previous git reauthor command
https://github.com/tardypad/git-extras/blob/stamp/bin/git-reauthor#L32
This was for multiple lines error message so that the second line is aligned with the : as in

error: missing target of the rewrite
       use either --old-email option or --all flag

It's not needed here, I better remove it then I guess

echo "${commit_msg}" \
| grep --ignore-case --invert-match "^${ID}\b" \
| cat --squeeze-blank
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed this is "unavoidable" the way it is
That's why I show the new commit message as a result, so that people can check that nothing went wrong.
But it's better to be explicit and I'll put a warning in the documentation

_git_stamp(){
__gitcomp '--replace -r'
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright I'll try to add it since that should be a simple one
I am not sure I'll be able to test it though
Configuring and switching to ZSH is still on my TODO list :)

@spacewander
Copy link
Collaborator

Waiting for your update...
Since we are making a new release this weekend, the git stamp will be included in next release.

@tardypad
Copy link
Contributor Author

tardypad commented Oct 7, 2016

Every review comment should be fixed within those last commits

@nicolaiskogheim
Copy link
Collaborator

@spacewander Any final thoughts?

@spacewander
Copy link
Collaborator

@tardypad
Sorry for the delay... Could you rebase the pull request so that we can merge it directly?

@tardypad
Copy link
Contributor Author

tardypad commented Dec 5, 2016

@spacewander I've rebased my branch against master yesterday
I'm not sure if you receive a notification in that case 🤔
So here is this message

@spacewander
Copy link
Collaborator

spacewander commented Dec 5, 2016 via email

@spacewander spacewander merged commit 82162ea into tj:master Dec 5, 2016
@spacewander
Copy link
Collaborator

Just introduced a new command to git-extras. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants