git-standup: add option to limit the number of commit

This commit is contained in:
spacewander 2019-11-04 11:36:29 +08:00
parent 227c19bb67
commit 952d1eb76f
4 changed files with 38 additions and 5 deletions

View file

@ -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] [-B]
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
@ -17,6 +17,7 @@ usage() {
-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
@ -61,7 +62,7 @@ fi
# which may fail on systems lacking tput or terminfo
set -e
while getopts "hgfBd:a:w:m:D:L" opt; do
while getopts "hgfBd:a:w:m:D:n:L" opt; do
case $opt in
h)
usage
@ -123,6 +124,9 @@ while getopts "hgfBd:a:w:m:D:L" opt; do
B)
GROUP_BY_BRANCHES=true
;;
n)
MAX_COMMIT_NUM=${OPTARG}
;;
\?)
usage
exit 1
@ -161,6 +165,9 @@ 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

View file

@ -7,7 +7,7 @@
\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] [\-B]
\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
@ -72,6 +72,12 @@ The former version of \fBgit standup\fR accepted \fB<author> <since> <until>\fR
.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:
.

View file

@ -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] [-B]</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>
@ -126,6 +126,16 @@ This interface is deprecated now, and please avoid to use it!</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>

View file

@ -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] [-B]
`git-standup` [-a author] [-m depth] [-d days ago] [-D date format] [-g] [-L] [-f] [-B] [-n number of commits]
`git-standup` -h
@ -53,6 +53,16 @@ This interface is deprecated now, and please avoid to use it!
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: