Add git coauthor command

This adds a feature to add additional authors to the previous commit,
this feature is supported by GitHub and GitLab and based on the format
should be self-evident to anyone reading the commit message.
This commit is contained in:
jacobherrington 2019-08-23 20:21:43 -05:00
parent ebdebadd3b
commit 66288296b2
8 changed files with 236 additions and 0 deletions

View file

@ -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)
@ -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 user@email.com
[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 <userperson@email.com>
Date: Sat Aug 17 17:33:53 2019 -0500
Add documentation files
Co-authored-by: user <user@email.com>
```
## git commits-since
List commits since `date` (defaults to "last week"):

4
bin/git-coauthor Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
old_message="$(git log --format=%B -n1)"
git commit --amend -m "$old_message" -m "Co-authored-by: $1 <$2>"

View file

@ -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 \
@ -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' \

42
man/git-coauthor.1 Normal file
View file

@ -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
man/git-coauthor.html Normal file
View file

@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='content-type' value='text/html;charset=utf8'>
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
<title>git-coauthor(1) - Add a co-author to the last commit</title>
<style type='text/css' media='all'>
/* style: man */
body#manpage {margin:0}
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
.mp h2 {margin:10px 0 0 0}
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
.mp h3 {margin:0 0 0 4ex}
.mp dt {margin:0;clear:left}
.mp dt.flush {float:left;width:8ex}
.mp dd {margin:0 0 0 9ex}
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
.mp pre {margin-bottom:20px}
.mp pre+h2,.mp pre+h3 {margin-top:22px}
.mp h2+pre,.mp h3+pre {margin-top:5px}
.mp img {display:block;margin:auto}
.mp h1.man-title {display:none}
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
.mp h2 {font-size:16px;line-height:1.25}
.mp h1 {font-size:20px;line-height:2}
.mp {text-align:justify;background:#fff}
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
.mp u {text-decoration:underline}
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
.mp b.man-ref {font-weight:normal;color:#434241}
.mp pre {padding:0 4ex}
.mp pre code {font-weight:normal;color:#434241}
.mp h2+pre,h3+pre {padding-left:0}
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
ol.man-decor {width:100%}
ol.man-decor li.tl {text-align:left}
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
ol.man-decor li.tr {text-align:right;float:right}
</style>
</head>
<!--
The following styles are deprecated and will be removed at some point:
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
.man-navigation should be used instead.
-->
<body id='manpage'>
<div class='mp' id='man'>
<div class='man-navigation' style='display:none'>
<a href="#NAME">NAME</a>
<a href="#SYNOPSIS">SYNOPSIS</a>
<a href="#DESCRIPTION">DESCRIPTION</a>
<a href="#OPTIONS">OPTIONS</a>
<a href="#EXAMPLES">EXAMPLES</a>
<a href="#AUTHOR">AUTHOR</a>
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
<a href="#SEE-ALSO">SEE ALSO</a>
</div>
<ol class='man-decor man-head man head'>
<li class='tl'>git-coauthor(1)</li>
<li class='tc'>Git Extras</li>
<li class='tr'>git-coauthor(1)</li>
</ol>
<h2 id="NAME">NAME</h2>
<p class="man-name">
<code>git-coauthor</code> - <span class="man-whatis">Add a co-author to the last commit</span>
</p>
<h2 id="SYNOPSIS">SYNOPSIS</h2>
<p><code>git-coauthor</code> &lt;co-author&gt; &lt;co-author-email&gt;</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<p> Add a co-author to the last commit</p>
<h2 id="OPTIONS">OPTIONS</h2>
<p> &lt;co-author&gt;</p>
<p> The username of the co-author you want to add.</p>
<p> &lt;co-author-email&gt;</p>
<p> The email address of the author you want to add.</p>
<h2 id="EXAMPLES">EXAMPLES</h2>
<pre><code>$ git coauthor user user@email.com
</code></pre>
<h2 id="AUTHOR">AUTHOR</h2>
<p>Written by Jacob Herrington <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#106;&#97;&#99;&#x6f;&#98;&#104;&#x65;&#x72;&#114;&#105;&#110;&#x67;&#116;&#x6f;&#x6e;&#x64;&#x65;&#x76;&#x65;&#x6c;&#111;&#112;&#x65;&#x72;&#64;&#103;&#109;&#x61;&#105;&#108;&#x2e;&#99;&#111;&#109;" data-bare-link="true">&#x6a;&#97;&#99;&#111;&#98;&#104;&#101;&#114;&#114;&#105;&#x6e;&#x67;&#x74;&#111;&#110;&#100;&#x65;&#118;&#101;&#108;&#111;&#x70;&#101;&#114;&#64;&#103;&#109;&#x61;&#105;&#x6c;&#x2e;&#99;&#x6f;&#x6d;</a></p>
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
<p>&lt;<a href="https://github.com/tj/git-extras/issues" data-bare-link="true">https://github.com/tj/git-extras/issues</a>&gt;</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p>&lt;<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>&gt;</p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>August 2019</li>
<li class='tr'>git-coauthor(1)</li>
</ol>
</div>
</body>
</html>

36
man/git-coauthor.md Normal file
View file

@ -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 user@email.com
## AUTHOR
Written by Jacob Herrington <jacobherringtondeveloper@gmail.com>
## REPORTING BUGS
&lt;<https://github.com/tj/git-extras/issues>&gt;
## SEE ALSO
&lt;<https://github.com/tj/git-extras>&gt;

View file

@ -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
- **git-commits-since(1)** Show commit logs since some date
- **git-contrib(1)** Show user's contributions
- **git-count(1)** Show commit count

View file

@ -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