Skip to content

Commit

Permalink
Merge pull request tj#525 from spacewander/git-standup
Browse files Browse the repository at this point in the history
add git standup
  • Loading branch information
hemanth committed Apr 19, 2016
2 parents 3e67b7a + 6e64136 commit 375c727
Show file tree
Hide file tree
Showing 6 changed files with 411 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- [`git scp`](#git-scp)
- [`git sed`](#git-sed)
- [`git setup`](#git-setup)
- [`git standup`](#git-standup)
- [`git squash`](#git-squash)
- [`git summary`](#git-summary)
- [`git sync`](#git-sync)
Expand Down Expand Up @@ -793,6 +794,13 @@ Internally this script uses `rsync` and not `scp` as the name suggests.

$ git scp staging js/vendor/

## git standup

Recall what you did or find what someone else did in a given range of time.
For instance, recall John's commits since last week:
```
git standup John "last week"
```
## git touch
Expand Down
90 changes: 90 additions & 0 deletions bin/git-standup
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash

# Code modified from https://github.com/kamranahmedse/git-standup,
# under the MIT LICENSE.
if [[ $# -gt 3 ]] ; then
>&2 printf "Usage: $0 [fullname] [since] [until]\nExample: $0 \"John Doe\" \"last Mon\" yesterday\n"
exit 1
fi

git rev-parse --show-toplevel > /dev/null 2>&1
in_git_repo=$?

# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [[ -t 1 ]] && [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] ; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
BOLD=$(tput bold)
UNDERLINE=$(tput smul)
NORMAL=$(tput sgr0)
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
BOLD=""
UNDERLINE=""
NORMAL=""
fi

# Only enable exit-on-error after the non-critical colorization stuff,
# which may fail on systems lacking tput or terminfo
set -e

AUTHOR=${1:-"$(git config user.name)"}
SINCE=${2:-yesterday}
UNTIL=${3:-today}


## In case it is the start of week, we need to
## show the commits since the last weekend
shopt -s nocasematch

GIT_LOG_COMMAND="git --no-pager log \
--all
--no-merges
--since \"$SINCE\"
--until \"$UNTIL\"
--author=\"$AUTHOR\"
--abbrev-commit
--oneline
--pretty=format:'%Cred%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"

## For when the command has been run in a non-repo directory
if [[ $in_git_repo != 0 ]]; then

## Iterate through all the top level directories inside
## and look for any git repositories.
for DIR in */ ; do

cd "$DIR"

## Show the detail only if it is a git repository
if [[ -d ".git" ]] ; then
if GITOUT=$(eval ${GIT_LOG_COMMAND}); then
## Only output if there is some activity
if [[ ! -z "$GITOUT" ]] ; then
echo "${BOLD}${UNDERLINE}${YELLOW}$DIR${NORMAL}"
echo "$GITOUT"
fi
else
echo "Repository under $DIR could not be queried. Missing initial commit?" >&2
fi
fi

cd ..
done
else
eval ${GIT_LOG_COMMAND}
echo "" ## To avoid that ugly # icon representing the end of line
fi
94 changes: 94 additions & 0 deletions man/git-standup.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-STANDUP" "1" "April 2016" "" ""
.
.SH "NAME"
\fBgit\-standup\fR \- Recall the commit history
.
.SH "SYNOPSIS"
\fBgit\-standup\fR [<full name>] [<since>] [<until>]
.
.SH "DESCRIPTION"
Recall what you did on the last working day \.\.or be nosy and find what someone else did\.
.
.SH "OPTIONS"
<full name>
.
.P
The author of commits\. Defaults to \fB$(git config user\.name)\fR\.
.
.P
<since>
.
.P
The start of commit history\. Defaults to \fByesterday\fR\.
.
.P
<until>
.
.P
The end of commit history\. Defaults to \fBtoday\fR\.
.
.SH "EXAMPLES"
This shows your commits since yesterday:
.
.IP "" 4
.
.nf

$ git standup

a26d1f9 \- add profile hook (69 minutes ago) <spacewander>
.
.fi
.
.IP "" 0
.
.P
This shows the author\'s commits since last week:
.
.IP "" 4
.
.nf

$ git standup spacewander "last week"

a26d1f9 \- add profile hook (70 minutes ago) <spacewander>
4e19859 \- fix getTotalSize return value error (6 days ago) <spacewander>
36da84e \- fix rename over bound (7 days ago) <spacewander>
8e4182a \- add watermark\.png (7 days ago) <spacewander>
46fef1d \- use tinyXML to configure (7 days ago) <spacewander>
.
.fi
.
.IP "" 0
.
.P
If current directory is not a git repo, git\-standup will fetch data from all top\-level git repos under it:
.
.IP "" 4
.
.nf

$ cd \.\.
$ git standup spacewander "last week" yesterday

someProject/
4e19859 \- fix getTotalSize return value error (6 days ago) <spacewander>
36da84e \- fix rename over bound (7 days ago) <spacewander>
8e4182a \- add watermark\.png (7 days ago) <spacewander>
46fef1d \- use tinyXML to configure (7 days ago) <spacewander>
.
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Originally from https://github\.com/kamranahmedse/git\-standup
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
152 changes: 152 additions & 0 deletions man/git-standup.html

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

Loading

0 comments on commit 375c727

Please sign in to comment.