Skip to content
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 git coauthor command #772

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [`git chore`](#git-featurerefactorbugchore)
- [`git clear`](#git-clear)
- [`git clear-soft`](#git-clear-soft)
- [`git coauthor`](#git-coauthor)
- [`git commits-since`](#git-commits-since)
- [`git contrib`](#git-contrib)
- [`git count`](#git-count)
Expand Down Expand Up @@ -347,6 +348,30 @@ Straight from the shell!
git (master)> quit
```

## git coauthor

Add a co-author to the last commit

```bash
$ git coauthor user [email protected]

[master b62ceae] Add documentation files
Date: Sat Aug 17 17:33:53 2019 -0500
2 files changed, 145 insertions(+), 0 deletions(-)
create mode 100644 README.md
create mode 100644 CONTRIBUTING.md

$ git log -1

commit b62ceae2685e6ece071f3c3754e9b77fd0a35c88 (HEAD -> master)
Author: user person <[email protected]>
Date: Sat Aug 17 17:33:53 2019 -0500

Add documentation files

Co-authored-by: user <[email protected]>
```

## git commits-since

List commits since `date` (defaults to "last week"):
Expand Down
10 changes: 10 additions & 0 deletions bin/git-coauthor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
jacobherrington marked this conversation as resolved.
Show resolved Hide resolved

jacobherrington marked this conversation as resolved.
Show resolved Hide resolved
coauthor=$1
email=$2

test -z $coauthor && echo "co-author required." 1>&2 && exit 1
jacobherrington marked this conversation as resolved.
Show resolved Hide resolved
test -z $email && echo "co-author email required." 1>&2 && exit 1

old_message="$(git log --format=%B -n1)"
jacobherrington marked this conversation as resolved.
Show resolved Hide resolved
git commit --amend -m "$old_message" -m "Co-authored-by: $coauthor <$email>"
6 changes: 6 additions & 0 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ _git-chore() {
'(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
}

_git-coauthor() {
_arguments \
':co-author[co-author to add]' \
':co-author-email[email address of co-author to add]'
}

_git-contrib() {
_arguments \
Expand Down Expand Up @@ -441,6 +446,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
chore:'create chore branch' \
clear-soft:'soft clean up a repository' \
clear:'rigorously clean up a repository' \
coauthor: 'add a co-author to the last commit' \
commits-since:'show commit logs since some date' \
contrib:'show user contributions' \
count:'show commit count' \
Expand Down
42 changes: 42 additions & 0 deletions man/git-coauthor.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-COAUTHOR" "1" "August 2019" "" "Git Extras"
.
.SH "NAME"
\fBgit\-coauthor\fR \- Add a co\-author to the last commit
.
.SH "SYNOPSIS"
\fBgit\-coauthor\fR <co\-author> <co\-author\-email>
.
.SH "DESCRIPTION"
Add a co\-author to the last commit
.
.SH "OPTIONS"
<co\-author>
.
.P
The username of the co\-author you want to add\.
.
.P
<co\-author\-email>
.
.P
The email address of the author you want to add\.
.
.SH "EXAMPLES"
.
.nf

$ git coauthor user user@email\.com
.
.fi
.
.SH "AUTHOR"
Written by Jacob Herrington \fIjacobherringtondeveloper@gmail\.com\fR
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
121 changes: 121 additions & 0 deletions man/git-coauthor.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions man/git-coauthor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
git-coauthor(1) -- Add a co-author to the last commit
================================

## SYNOPSIS

`git-coauthor` &lt;co-author&gt; &lt;co-author-email&gt;

## DESCRIPTION

Add a co-author to the last commit

## OPTIONS

&lt;co-author&gt;

The username of the co-author you want to add.

&lt;co-author-email&gt;

The email address of the author you want to add.

## EXAMPLES

$ git coauthor user [email protected]

## AUTHOR

Written by Jacob Herrington <[email protected]>

## REPORTING BUGS

&lt;<https://github.com/tj/git-extras/issues>&gt;

## SEE ALSO

&lt;<https://github.com/tj/git-extras>&gt;
1 change: 1 addition & 0 deletions man/git-extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ git-extras(1) -- Awesome GIT utilities
- **git-chore(1)** Create chore branch
- **git-clear-soft(1)** Soft clean up a repository
- **git-clear(1)** Rigorously clean up a repository
- **git-coauthor(1)** Add a co-author to the last commit
jacobherrington marked this conversation as resolved.
Show resolved Hide resolved
- **git-commits-since(1)** Show commit logs since some date
- **git-contrib(1)** Show user's contributions
- **git-count(1)** Show commit count
Expand Down
1 change: 1 addition & 0 deletions man/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ git-changelog(1) git-changelog
git-chore(1) git-chore
git-clear-soft(1) git-clear-soft
git-clear(1) git-clear
git-coauthor(1) git-coauthor
git-commits-since(1) git-commits-since
git-contrib(1) git-contrib
git-count(1) git-count
Expand Down