Repository: kamranahmedse/git-standup Branch: master Commit: a8031b896367 Files: 11 Total size: 20.3 KB Directory structure: gitextract_gabn08pw/ ├── .github/ │ └── FUNDING.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── actions/ │ ├── shellcheck │ └── shfmt ├── git-standup ├── installer.sh ├── package.json └── snap/ └── snapcraft.yaml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: kamranahmedse ================================================ FILE: .gitignore ================================================ .idea .DS_Store ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Kamran Ahmed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: Makefile ================================================ PREFIX ?= /usr/local EXEC_PREFIX ?= $(PREFIX) BINDIR ?= $(EXEC_PREFIX)/bin DATAROOTDIR ?= $(PREFIX)/share DATADIR ?= $(DATAROOTDIR) MANDIR ?= $(DATAROOTDIR)/man # files that need mode 755 EXEC_FILES = git-standup .PHONY: check all install uninstall shellcheck shfmt all: @echo "usage: make install" @echo " make uninstall" install: mkdir -p $(BINDIR) install -m 0755 $(EXEC_FILES) $(BINDIR) uninstall: test -d $(BINDIR) && \ cd $(BINDIR) && \ rm -f $(EXEC_FILES) check: shellcheck shfmt shellcheck: ./actions/shellcheck shfmt: ./actions/shfmt ================================================ FILE: README.md ================================================ # git-standup > Recall what you did on the last working day ..or be nosy and find what someone else did. A little tool that I always wanted for myself. I work on several repositories on daily basis and it is mostly difficult for me to remember where I left off in each one of them. `git-standup` helps me with running standups and keeping track of what I have been doing. By default it gives you the most common usage i.e. shows you commits from the last working day in the current directory and the directories below current level plus it comes with several options to modify how it behaves. ## Requirements The only requirement is having good commit messages :) ![](https://i.imgur.com/yL03GkB.png) ## Install You can install `git-standup` using one of the options listed below | Source | Command | | --- | --- | | curl | `curl -L https://raw.githubusercontent.com/kamranahmedse/git-standup/master/installer.sh \| sudo sh` | | npm | `npm install -g git-standup` | | brew | `brew update && brew install git-standup` | | aur | `pacaur -S git-standup-git` | | manual | Clone and run `make install` | ## Usage Simply run it in your project directory and it will give you the output from the last working day ```shell git standup ``` If you run it in a folder containing multiple git repositories, it will go through each of the projects and give you the standup report for each one of them. ## Options You can pass several options to modify how git-standup behaves ```shell git standup [-a ] [-w ] [-m ] [-F] [-b ] [-d ] [-u ] [-D ] [-A ] [-B ] [-L] [-g] [-h] [-f] [-s] [-r] [-c] [-R] ``` Here is the detail for each of the options | Option | Description | | --- | --- | | a | Specify author to restrict search to e.g. `-a "Kamran Ahmed"` or `-a "all"` | | b | Specify branch to restrict search to (unset: all branches, "\$remote/\$branch" to include fetches) | | w | Specify week start and end days e.g. in UAE weekdays are from Sunday to Thursday so you can do `-w SUN-THU`| | m | Specify the depth of recursive directory search e.g. `-m 3` defaults to two | | F | Force recursion up to specified depth even when git repository found earlier | | d | Specify the number of days back to include e.g. `-d 30` to get for a month | | u | Specify the number of days back till which standup should run e.g. `-u 3` | | L | Toggle inclusion of symbolic links in recursive directory search | | D | Specify the date format for "git log" (default: relative) [possible values](https://git-scm.com/docs/git-log#Documentation/git-log.txt---dateltformatgt) | | A | Show the commits till after the given date | B | Show the commits till before the given date | h | Display the help screen | | g | Show if commit is GPG signed (G) or not (N) | | f | Fetch the latest commits beforehand | | s | Silences the no activity message (useful when running in a directory having many repositories) | | c | Show diff-stat for every matched commit | r | Generates the standup report file `git-standup-report.txt` in the current directory | | R | Display the author date instead of the committer date | For the basic usage, all you have to do is run `git standup` in a repository or a folder containing multiple repositories ## Single Repository Usage To check all your personal commits from last working day, head to the project repository and run ```shell $ git standup ``` ![git standup](http://i.imgur.com/wyo4s9E.gif) ## Multiple Repository Usage Open a directory having multiple repositories and run ```shell $ git standup ``` ![git standup](http://i.imgur.com/4xmkA49.gif) This will show you all your commits since the last working day in all the repositories inside. ## Directory depth By default the script searches only in the current directory or one level deep. If you want to increase that, use the `-m` switch. If the base directory is a git repository you can use the `-F` switch to force the recursion. ```shell $ git standup -m 3 ``` ## Checking someone else's commits If you want to find out someone else's commits do ```shell # Considering their name on git is "John Doe" $ git standup -a "John Doe" ``` Apart from restrict to commits from a certain user, you can also use `-a` flag to avoid certain users. You can do that if you enable perl regexp in your git installation `git config --global grep.patternType perl`, and use the author filter like below: ```shell git standup -a'^(?!(renovate\[bot\]))' ``` ![git standup](http://i.imgur.com/sYICxW8.gif) ## Check what every contributor did If you want to find out someone else's commits do ```shell $ git standup -a "all" ``` ## Commits from `n` days ago If you would like to show all your/someone else's commits from n days ago, you can do ```shell # Show all my commits from 4 days ago $ git standup -d 4 # Show all John Doe's commits from 5 days ago $ git standup -a "John Doe" -d 5 ``` ![git standup -d 5](http://i.imgur.com/j7Ma760.gif) ## Date filters You can apply the filters on the commits shown. Use `-A` and `-B` flags to specify `after` and `before` dates ```shell # Show all the commits after October 01, 2018 git standup -A "2018-10-01 00:00" # Show all the commits till before October 01, 2018 git standup -B "2018-10-01 00:00" # Show the commits between September 20 and September 30 git standup -A "2018-09-20 00:00:00" -B "2018-09-30 23:59" ``` ## Show Diff-stat Add `-c` flag to show the diff-stat for each of the commits in standup results ```shell git standup -c ``` ## [Identifying Signed Commits](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work) Add `-g` flag to check the GPG info ```shell $ git standup -g ``` ![GPG Info](http://i.imgur.com/bwJzPft.gif) ## Specifying the date format Add `-D` flag to specify the date format. Default is `relative` Please note that it accepts the same format that you could pass while doing git log. For example ```shell $ git standup -D relative # Or instead of relative, it could be local|default|iso|iso-strict|rfc|short|raw etc ``` ## Branch Filter Use of `-b foobar` option, which restricts returned results to commits present on branch `foobar`. Supports arbitrary branch specs, so for example `-b origin/foobar` would include data present on the remote that has not been merged locally. ```shell # Use develop branch for standup git standup -b develop ``` ### Directory whitelisting If you want to restrict the standup to some paths, you can whitelist them by adding them to a `.git-standup-whitelist` file. For example if you have the below directory structure ├── Workspace # All your projects are here │ ├── project-a # Some git repository called project-a │ ├── project-b # Some git repository called project-b │ ├── sketch-files # Some sketch files │ ├── mockups # Some balsamiq mockups │ └── ... # etc. └── ... And you want the `git-standup` to show logs for only `project-a` and `project-b`, you can do that by creating a `.git-standup-whitelist` file under the `Workspace` directory with the below contents and it will only consider these directories for the standup ``` project-a project-b ``` ## Changing the Weekdays By default, it considers that the work week starts on Monday and ends on Friday. So if you are running this on any day between Tuesday and Friday, it will show you your commits from the last day. However, if you are running this on Monday, it will show you all your commits since Friday. If you want to change this, like I want because here in Dubai working days are normally Sunday to Thursday, you will have to do the following ```shell $ git standup -w "SUN-THU" ``` ## Fetch commits before showing standup If you have many repositories that you want to generate a standup for, it may be useful to automatically run `git fetch` before viewing the standup. If you would like to automatically run `git fetch --all` before printing the standup, you can add the `-f` flag, as show below ```shell $ git standup -f ``` ## Mixing options Of course you can mix the options together but please note that if you provide the number of days, it will override the weekdays configuration (`MON-FRI`) and will show you the commits specifically from `n` days ago. ```shell # Show all the John Doe's commits from 5 days ago $ git standup -a "John Doe" -d 5 ``` ## License MIT © [Kamran Ahmed](http://kamranahmed.info) ================================================ FILE: actions/shellcheck ================================================ #! /usr/bin/env bash set -euo pipefail root="$(git rev-parse --show-toplevel)" cd "$root" { # `.sh` extension git ls-files '*.sh' # `#! usr/bin/env bash` shebang git grep -l '^\(#! */usr/bin/env bash\|#! */bin/bash\)$' # remove duplicates from .sh + shebang } | sort | uniq | xargs shellcheck || exit 1 ================================================ FILE: actions/shfmt ================================================ #! /usr/bin/env bash set -euo pipefail root="$(git rev-parse --show-toplevel)" cd "$root" { # `.sh` extension git ls-files '*.sh' # `#! usr/bin/env bash` shebang git grep -l '^\(#! */usr/bin/env bash\|#! */bin/bash\)$' # remove duplicates from .sh + shebang # 2 space indentation, allow binary ops (`&&`, `||`, etc.) to start lines, # indent switch cases & add spaces after redirect operators. } | sort | uniq | xargs shfmt -i 2 -bn -ci -sr -w || exit 1 ================================================ FILE: git-standup ================================================ #!/usr/bin/env bash # shellcheck disable=SC2128 # Shows the usage function usage() { cat << EOS Usage: git standup [-a ] [-w ] [-d ] [-u ] [-m ] [-g] [-h] [-f] [-c] -a - Specify author to restrict search to or use "all" to see all authors -b - Specify branch to restrict search to (unset: all branches, "\$remote/\$branch" to include fetches) -w - Specify weekday range to limit search to -m - Specify the depth of recursive directory search -F - Force recursion up to specified depth -L - Toggle inclusion of symbolic links in recursive directory search -d - Specify the number of days back to include -u - Specify the number of days back until this day -D - Specify the date format for "git log" (default: relative, other: local|default|iso|rfc|short|raw) -h - Display this help screen -g - Show if commit is GPG signed (G) or not (N) -f - Fetch the latest commits beforehand -s - Silences the no activity message (useful when running in a directory having many repositories) -r - Generate a file with the report -c - Show diffstat for every matched commit -A - List commits after this date -B - List commits before this date -R - Display the author date instead of the committer date Examples: git standup -a "John Doe" -w "MON-FRI" -m 3 EOS } # Sets up the colored output function colored() { RED=$(tput setaf 1) GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) BLUE=$(tput setaf 4) BOLD=$(tput bold) UNDERLINE=$(tput smul) NORMAL=$(tput sgr0) GIT_PRETTY_DATE="%cd" if [[ ${option_R:=} ]]; then GIT_PRETTY_DATE="%ad" fi GIT_PRETTY_FORMAT="%Cred%h%Creset - %s %Cgreen($GIT_PRETTY_DATE) %C(bold blue)<%an>%Creset" COLOR=always if [[ ${option_g:=} ]]; then GIT_PRETTY_FORMAT="$GIT_PRETTY_FORMAT %C(yellow)gpg: %G?%Creset" fi } # Sets up the uncolored output function uncolored() { # shellcheck disable=SC2034 RED="" GREEN="" YELLOW="" # shellcheck disable=SC2034 BLUE="" BOLD="" UNDERLINE="" NORMAL="" GIT_PRETTY_DATE="%cd" if [[ $option_R ]]; then GIT_PRETTY_DATE="%ad" fi GIT_PRETTY_FORMAT="%h - %s ($GIT_PRETTY_DATE) <%an>" COLOR=never if [[ $option_g ]]; then GIT_PRETTY_FORMAT="$GIT_PRETTY_FORMAT gpg: %G?\n" else GIT_PRETTY_FORMAT="$GIT_PRETTY_FORMAT \n" fi } function writeFile() { echo -e "$1" >> "${REPORT_FILE_PATH}" } function runStandup() { # Fetch the latest commits, if required if [[ ${option_f:=} ]]; then echo "${BOLD}${GREEN}Fetching commits in ${YELLOW}${UNDERLINE}${BOLD}${BASENAME}${NORMAL}" git fetch --all > /dev/null 2>&1 fi { # shellcheck disable=SC2086 GITOUT=$(eval ${GIT_LOG_COMMAND} 2> /dev/null) } || { GITOUT="" } # If `r` option was given then no output, just write the report if [[ -n ${option_r:=} ]]; then echo "Generating report for: ${CUR_DIR}" if [[ -n "$GITOUT" ]]; then writeFile "${CUR_DIR}\n $GITOUT" elif [[ -z ${option_s:=} ]]; then writeFile "${CUR_DIR}\n No activity found!\n" fi else ## Only output if there is some activity if [[ -n "$GITOUT" ]]; then echo "${BOLD}${UNDERLINE}${YELLOW}$CUR_DIR${NORMAL}" echo "$GITOUT" elif [[ -z $option_s ]]; then ## Show the no activity message only if the `s` flag is not there echo "${BOLD}${UNDERLINE}${YELLOW}$CUR_DIR${NORMAL}" if [[ ${AUTHOR} = '.*' ]]; then echo "${YELLOW}No commits found during this period.${NORMAL}" else echo "${YELLOW}No commits from $AUTHOR during this period.${NORMAL}" fi fi fi } while getopts "hgfsd:u:a:w:m:D:A:B:LrcRFb:" opt; do case $opt in h | d | u | a | w | m | g | D | f | s | L | r | A | B | c | R | F | b) declare "option_$opt=${OPTARG:-0}" ;; \?) echo >&2 "Use 'git standup -h' to see usage info" exit 1 ;; esac done shift $((OPTIND - 1)) if [[ $# -gt 0 ]]; then echo >&2 "Invalid arguments: $*" echo >&2 "Use 'git standup -h' to see usage info" exit 1 fi # Main script if [[ ${option_h:=} ]]; then usage exit 0 fi # Use colors, but only if connected to a terminal, and that terminal supports them. if [[ -t 1 ]] && [[ -n "$TERM" ]] && command -v tput &> /dev/null && tput colors &> /dev/null; then ncolors=$(tput colors) if [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] && [[ -z "$option_r" ]]; then colored else uncolored fi else uncolored fi ## Set the necessary variables for standup SINCE="yesterday" MAXDEPTH=2 INCLUDE_LINKS= RAN_FROM_DIR=$(pwd) REPORT_FILE_PATH="${RAN_FROM_DIR}/git-standup-report.txt" STAT= # If report is to be generated, remove the existing report file if any if [[ -n $option_r ]]; then rm -rf "${REPORT_FILE_PATH}" fi if [[ ${option_m:=} ]]; then MAXDEPTH="$((${option_m:=} + 1))" fi if [[ ${option_L:=} ]]; then INCLUDE_LINKS="-L" fi if [[ ${option_c:=} ]]; then STAT="--stat" fi ## If -d flag is there, use its value for the since if [[ ${option_d:=} ]] && [[ $option_d -ne 0 ]]; then SINCE="$option_d days ago" else ## -d flag is not there, go on with the normal processing WEEKSTART="$(cut -d '-' -f 1 <<< "${option_:=w}")" WEEKSTART=${WEEKSTART:="Mon"} WEEKEND="$(cut -d '-' -f 2 <<< "${option_w:=}")" WEEKEND=${WEEKEND:="Fri"} ## In case it is the start of week, we need to ## show the commits since the last weekend shopt -s nocasematch if [[ ${WEEKSTART} == "$(date +%a)" ]]; then SINCE="last $WEEKEND" fi fi ## If -u flag is there, use its value for the until if [[ ${option_u:=} ]] && [[ $option_u -ne 0 ]]; then UNTIL_OPT="--until=\"$option_u days ago\"" elif [[ ${option_B:=} ]]; then UNTIL_OPT="--until=\"$option_B\"" fi if [[ ${option_A:=} ]]; then AFTER_OPT="--after=\"$option_A\"" fi GIT_DATE_FORMAT=${option_D:-relative} # For when the command has been run in a non-repo directory if [[ ${option_F:=} || ! -d ".git" || -f ".git" ]]; then BASE_DIR=$(pwd) # Set delimiter to newline for the loop IFS=$'\n' if [[ -f ".git-standup-whitelist" ]]; then SEARCH_PATH=$(cat .git-standup-whitelist) else SEARCH_PATH=. fi # Recursively search for git repositories PROJECT_DIRS=$(find ${INCLUDE_LINKS} ${SEARCH_PATH} -maxdepth ${MAXDEPTH} -mindepth 0 -name .git) elif [[ -f ".git" || -d ".git" ]]; then PROJECT_DIRS=("$(pwd)/.git") fi # if project directories is still empty # we might be sitting inside a git repo if [[ -z ${PROJECT_DIRS} ]]; then ROOT_DIR_COMMAND="git rev-parse --show-toplevel" PROJECT_ROOT=$(eval "${ROOT_DIR_COMMAND}" 2> /dev/null) if [[ -z ${PROJECT_ROOT} ]]; then echo "${YELLOW}You must be inside a git repository!${NORMAL}" exit 0 fi PROJECT_DIRS=("${PROJECT_ROOT}/.git") fi # Foreach of the project directories, run the standup IFS=$'\n' for DIR in ${PROJECT_DIRS}; do PROJECT_DIR=$(dirname "$DIR") cd "$PROJECT_DIR" || exit CUR_DIR=$(pwd) BASENAME=$(basename "$CUR_DIR") # continue if not a git directory if [[ ! -d ".git" || -f ".git" ]]; then cd "${BASE_DIR}" || exit continue fi AUTHOR=$(git config user.name) if [[ ${option_a:=} ]]; then # In case the parameter if [[ $option_a = 'all' ]]; then AUTHOR=".*" else AUTHOR="$option_a" fi fi GIT_BRANCH_FILTER="--all" if [[ ${option_b:=} ]]; then GIT_BRANCH_FILTER="--first-parent $option_b" fi GIT_LOG_COMMAND="git --no-pager log \ ${GIT_BRANCH_FILTER} --no-merges --since=\"$SINCE\" ${UNTIL_OPT} ${AFTER_OPT} --author=\"$AUTHOR\" --abbrev-commit --oneline --pretty=format:'$GIT_PRETTY_FORMAT' --date='$GIT_DATE_FORMAT' --color=$COLOR ${STAT}" runStandup cd "${BASE_DIR}" || exit done unset IFS ================================================ FILE: installer.sh ================================================ #!/usr/bin/env bash ## Clone the repo git clone https://github.com/kamranahmedse/git-standup.git --depth=1 || { echo >&2 "Clone failed with $?" exit 1 } cd git-standup || exit make install || { echo >&2 "Clone failed with $?" exit 1 } cd .. rm -rf git-standup ================================================ FILE: package.json ================================================ { "name": "git-standup", "version": "2.3.2", "description": "Recall what you did on the last working day. Psst! or be nosy and find what someone else in your team did ;-)", "main": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { "git-standup": "./git-standup" }, "repository": { "type": "git", "url": "git+https://github.com/kamranahmedse/git-standup.git" }, "keywords": [ "git", "standup" ], "author": "Kamran Ahmed", "license": "MIT", "bugs": { "url": "https://github.com/kamranahmedse/git-standup/issues" }, "homepage": "https://github.com/kamranahmedse/git-standup#readme" } ================================================ FILE: snap/snapcraft.yaml ================================================ name: git-standup base: core18 # the base snap is the execution environment for this snap version: git summary: Recall what you did on the last working day. description: | git-standup by default it gives you the most common usage i.e. shows you commits from the last working day in the current directory and the directories below current level plus it comes with several options to modify how it behaves. The only requirement is having good commit messages :) grade: stable confinement: strict parts: git-standup: plugin: nodejs source: . stage-packages: - git apps: git-standup: command: bin/git-standup plugs: - home - removable-media