mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Merge pull request #793 from spacewander/git-standup-group-by-branch
git-standup: add option '-B' to group the commits by branch
This commit is contained in:
commit
b0d3a77ac0
|
|
@ -5,7 +5,7 @@
|
|||
usage() {
|
||||
cat <<EOS
|
||||
Usage:
|
||||
git standup [-a <author name>] [-w <weekstart-weekend>] [-d <days-ago>] [-m <max-dir-depth>] [-g] [-h] [-f]
|
||||
git standup [-a <author name>] [-w <weekstart-weekend>] [-d <days-ago>] [-m <max-dir-depth>] [-g] [-h] [-f] [-B] [-n <number-of-commits]
|
||||
|
||||
-a - Specify author to restrict search to
|
||||
-w - Specify weekday range to limit search to
|
||||
|
|
@ -16,6 +16,8 @@ usage() {
|
|||
-h - Display this help screen
|
||||
-g - Show if commit is GPG signed (G) or not (N)
|
||||
-f - Fetch the latest commits beforehand
|
||||
-B - Display the commits in branch groups
|
||||
-n - Limit the number of commits displayed per group
|
||||
|
||||
Examples:
|
||||
git standup -a "John Doe" -w "MON-FRI" -m 3
|
||||
|
|
@ -60,7 +62,7 @@ fi
|
|||
# which may fail on systems lacking tput or terminfo
|
||||
set -e
|
||||
|
||||
while getopts "hgfd:a:w:m:D:L" opt; do
|
||||
while getopts "hgfBd:a:w:m:D:n:L" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
|
|
@ -119,6 +121,12 @@ while getopts "hgfd:a:w:m:D:L" opt; do
|
|||
g)
|
||||
GIT_PRETTY_FORMAT="%C(yellow)gpg: %G?%Creset"
|
||||
;;
|
||||
B)
|
||||
GROUP_BY_BRANCHES=true
|
||||
;;
|
||||
n)
|
||||
MAX_COMMIT_NUM=${OPTARG}
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
exit 1
|
||||
|
|
@ -148,7 +156,6 @@ GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen(%cd) %C(bold blue)<%an>%Creset $G
|
|||
GIT_DATE_FORMAT=${GIT_DATE_FORMAT:=relative}
|
||||
|
||||
GIT_LOG_COMMAND="git --no-pager log \
|
||||
--all
|
||||
--no-merges
|
||||
--since \"$SINCE\"
|
||||
--until \"$UNTIL\"
|
||||
|
|
@ -158,6 +165,30 @@ GIT_LOG_COMMAND="git --no-pager log \
|
|||
--color=$COLOR
|
||||
--pretty=format:'$GIT_PRETTY_FORMAT'
|
||||
--date='$GIT_DATE_FORMAT'"
|
||||
if [[ ! -z "$MAX_COMMIT_NUM" ]]; then
|
||||
GIT_LOG_COMMAND="$GIT_LOG_COMMAND --max-count=$MAX_COMMIT_NUM"
|
||||
fi
|
||||
|
||||
git_output() {
|
||||
if [ "$GROUP_BY_BRANCHES" = true ]; then
|
||||
local branches
|
||||
branches=$(git branch --sort=-committerdate | awk '{print substr($0, 3)}')
|
||||
for branch in $branches; do
|
||||
# shellcheck disable=SC2086
|
||||
if output=$(eval $GIT_LOG_COMMAND "$branch"); then
|
||||
if [[ ! -z "$output" ]] ; then
|
||||
echo "${GREEN}${branch}${NORMAL}"
|
||||
echo "$output"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
# TODO optimize:return if the latest commit of a branch is eariler than the 'since' day
|
||||
done
|
||||
else
|
||||
# shellcheck disable=SC2086
|
||||
eval $GIT_LOG_COMMAND --all
|
||||
fi
|
||||
}
|
||||
|
||||
## For when the command has been run in a non-repo directory
|
||||
if [[ $in_git_repo != 0 ]]; then
|
||||
|
|
@ -191,11 +222,12 @@ if [[ $in_git_repo != 0 ]]; then
|
|||
pushd "$DIR" > /dev/null
|
||||
## Show the detail only if it is a git repository
|
||||
if [[ -d ".git" || -f ".git" ]] ; then
|
||||
if GITOUT=$(eval ${GIT_LOG_COMMAND}); then
|
||||
if GITOUT=$(git_output); then
|
||||
## Only output if there is some activities
|
||||
if [[ ! -z "$GITOUT" ]] ; then
|
||||
echo "${BOLD}${UNDERLINE}${YELLOW}$(basename "$DIR")${NORMAL}"
|
||||
echo "$GITOUT"
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo "Repository under $DIR could not be queried." >&2
|
||||
|
|
@ -209,7 +241,7 @@ else
|
|||
git fetch --all > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
if GITOUT=$(eval ${GIT_LOG_COMMAND}); then
|
||||
if GITOUT=$(git_output); then
|
||||
if [[ ! -z "$GITOUT" ]] ; then
|
||||
echo "$GITOUT"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -418,7 +418,8 @@ _git-standup() {
|
|||
'-g[Display GPG signed info]' \
|
||||
'-h[Display help message]' \
|
||||
'-L[Enable the inclusion of symbolic links]' \
|
||||
'-m[The depth of recursive directory search]'
|
||||
'-m[The depth of recursive directory search]' \
|
||||
'-B[Display the commits in branch groups]'
|
||||
}
|
||||
|
||||
_git-summary() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-STANDUP" "1" "October 2017" "" "Git Extras"
|
||||
.TH "GIT\-STANDUP" "1" "November 2019" "" "Git Extras"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-standup\fR \- Recall the commit history
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-standup\fR [\-a author] [\-m depth] [\-d days ago] [\-D date format] [\-g] [\-L] [\-f]
|
||||
\fBgit\-standup\fR [\-a author] [\-m depth] [\-d days ago] [\-D date format] [\-g] [\-L] [\-f] [\-B] [\-n number of commits]
|
||||
.
|
||||
.P
|
||||
\fBgit\-standup\fR \-h
|
||||
|
|
@ -66,6 +66,18 @@ Fetch the latest commits before showing commit history\.
|
|||
.P
|
||||
The former version of \fBgit standup\fR accepted \fB<author> <since> <until>\fR as options\. This interface is deprecated now, and please avoid to use it!
|
||||
.
|
||||
.P
|
||||
\-B
|
||||
.
|
||||
.P
|
||||
Display the commits in branch groups\.
|
||||
.
|
||||
.P
|
||||
\-n number\-of\-commits
|
||||
.
|
||||
.P
|
||||
Limit the number of commits displayed per group\. By default, the limitation is applied in the repository level\. For example, if you have 3 repositories under the current directory, \fBgit standup \.\.\. \-n 1\fR will show you 3 commits at most\. When \fB\-B\fR is specific, the limitation is applied in the branch level\. For instance, if each of your 3 repositories have 2 branches, \fBgit standup \.\.\. \-B \-n 1\fR will display 6 commits at most\.
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
This shows your commits since yesterday:
|
||||
.
|
||||
|
|
@ -120,6 +132,31 @@ someProject/
|
|||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
By specifying the \fB\-B\fR option, git\-standuo will group the commits in branches:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git standup \-B \-a spacewander \-d 7
|
||||
|
||||
git\-summary\-cleanup
|
||||
f788c78 \- git\-summary: clean up other shellcheck warnings (23 hours ago) <spacewander>
|
||||
3e8c3ab \- git\-summary: fix incorrect active days when commits range is given (23 hours ago) <spacewander>
|
||||
ff991ac \- git\-summary: remove useless result function\. (23 hours ago) <spacewander>
|
||||
203f5b4 \- git\-summary: add \-\-dedup\-by\-email to remove duplicate users (5 days ago) <spacewander>
|
||||
|
||||
master
|
||||
203f5b4 \- git\-summary: add \-\-dedup\-by\-email to remove duplicate users (5 days ago) <spacewander>
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Note that the same commit can be seen in different branches\.
|
||||
.
|
||||
.SH "AUTHOR"
|
||||
Originally from https://github\.com/kamranahmedse/git\-standup
|
||||
.
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-standup</code> [-a author] [-m depth] [-d days ago] [-D date format] [-g] [-L] [-f]</p>
|
||||
<p><code>git-standup</code> [-a author] [-m depth] [-d days ago] [-D date format] [-g] [-L] [-f] [-B] [-n number of commits]</p>
|
||||
|
||||
<p><code>git-standup</code> -h</p>
|
||||
|
||||
|
|
@ -122,6 +122,20 @@ Defaults to <code>$(git config user.name)</code>.</p>
|
|||
<p>The former version of <code>git standup</code> accepted <code><author> <since> <until></code> as options.
|
||||
This interface is deprecated now, and please avoid to use it!</p>
|
||||
|
||||
<p>-B</p>
|
||||
|
||||
<p>Display the commits in branch groups.</p>
|
||||
|
||||
<p>-n number-of-commits</p>
|
||||
|
||||
<p>Limit the number of commits displayed per group.
|
||||
By default, the limitation is applied in the repository level. For example, if you
|
||||
have 3 repositories under the current directory, <code>git standup ... -n 1</code> will
|
||||
show you 3 commits at most.
|
||||
When <code>-B</code> is specific, the limitation is applied in the branch level. For instance,
|
||||
if each of your 3 repositories have 2 branches, <code>git standup ... -B -n 1</code> will
|
||||
display 6 commits at most.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p>This shows your commits since yesterday:</p>
|
||||
|
|
@ -154,6 +168,22 @@ someProject/
|
|||
46fef1d - use tinyXML to configure (7 days ago) <spacewander>
|
||||
</code></pre>
|
||||
|
||||
<p>By specifying the <code>-B</code> option, git-standuo will group the commits in branches:</p>
|
||||
|
||||
<pre><code>$ git standup -B -a spacewander -d 7
|
||||
|
||||
git-summary-cleanup
|
||||
f788c78 - git-summary: clean up other shellcheck warnings (23 hours ago) <spacewander>
|
||||
3e8c3ab - git-summary: fix incorrect active days when commits range is given (23 hours ago) <spacewander>
|
||||
ff991ac - git-summary: remove useless result function. (23 hours ago) <spacewander>
|
||||
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
|
||||
|
||||
master
|
||||
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
|
||||
</code></pre>
|
||||
|
||||
<p>Note that the same commit can be seen in different branches.</p>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Originally from https://github.com/kamranahmedse/git-standup</p>
|
||||
|
|
@ -169,7 +199,7 @@ someProject/
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>October 2017</li>
|
||||
<li class='tc'>November 2019</li>
|
||||
<li class='tr'>git-standup(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-standup(1) -- Recall the commit history
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-standup` [-a author] [-m depth] [-d days ago] [-D date format] [-g] [-L] [-f]
|
||||
`git-standup` [-a author] [-m depth] [-d days ago] [-D date format] [-g] [-L] [-f] [-B] [-n number of commits]
|
||||
|
||||
`git-standup` -h
|
||||
|
||||
|
|
@ -49,6 +49,20 @@ Fetch the latest commits before showing commit history.
|
|||
The former version of `git standup` accepted `<author> <since> <until>` as options.
|
||||
This interface is deprecated now, and please avoid to use it!
|
||||
|
||||
-B
|
||||
|
||||
Display the commits in branch groups.
|
||||
|
||||
-n number-of-commits
|
||||
|
||||
Limit the number of commits displayed per group.
|
||||
By default, the limitation is applied in the repository level. For example, if you
|
||||
have 3 repositories under the current directory, `git standup ... -n 1` will
|
||||
show you 3 commits at most.
|
||||
When `-B` is specific, the limitation is applied in the branch level. For instance,
|
||||
if each of your 3 repositories have 2 branches, `git standup ... -B -n 1` will
|
||||
display 6 commits at most.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
This shows your commits since yesterday:
|
||||
|
|
@ -78,6 +92,20 @@ If current directory is not a git repo, git-standup will fetch data from all top
|
|||
8e4182a - add watermark.png (7 days ago) <spacewander>
|
||||
46fef1d - use tinyXML to configure (7 days ago) <spacewander>
|
||||
|
||||
By specifying the `-B` option, git-standuo will group the commits in branches:
|
||||
|
||||
$ git standup -B -a spacewander -d 7
|
||||
|
||||
git-summary-cleanup
|
||||
f788c78 - git-summary: clean up other shellcheck warnings (23 hours ago) <spacewander>
|
||||
3e8c3ab - git-summary: fix incorrect active days when commits range is given (23 hours ago) <spacewander>
|
||||
ff991ac - git-summary: remove useless result function. (23 hours ago) <spacewander>
|
||||
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
|
||||
|
||||
master
|
||||
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
|
||||
|
||||
Note that the same commit can be seen in different branches.
|
||||
|
||||
## AUTHOR
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue