From 08d1a5a6e31a920a650dd4ceef3762a92a2731ca Mon Sep 17 00:00:00 2001 From: Matthieu Treussart Date: Tue, 18 May 2021 21:51:40 +0200 Subject: [PATCH] Set git branch in options --- README.md | 8 ++++++++ git-quick-stats | 10 ++++++---- git-quick-stats.1 | 10 +++++++--- tests/commands_test.sh | 4 +++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 68e526d..26f9a40 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,14 @@ export _GIT_MERGE_VIEW="enable" export _GIT_MERGE_VIEW="exclusive" ``` +### Git branch + +You can set the variable `_GIT_BRANCH` to set the branch of the stats. Works with commands `--git-stats-by-branch`. + +```bash +export _GIT_BRANCH="master" +``` + ### Color themes You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy` diff --git a/git-quick-stats b/git-quick-stats index f7ec390..e685816 100755 --- a/git-quick-stats +++ b/git-quick-stats @@ -61,7 +61,7 @@ fi _log_options=${_GIT_LOG_OPTIONS:-} if [[ -n "${_log_options}" ]]; then _log_options=$_log_options -else +else _log_options="" fi @@ -158,7 +158,9 @@ ADDITIONAL USAGE You can also set _GIT_MERGE_VIEW to only show merge commits ex: export _GIT_MERGE_VIEW=exclusive You can set _MENU_THEME to display the legacy color scheme - ex: export _MENU_THEME=legacy" + ex: export _MENU_THEME=legacy + You can set _GIT_BRANCH to set the branch of the stats + ex: export _GIT_BRANCH=master" } ################################################################################ @@ -457,7 +459,7 @@ function commitsByHour() { _author="--author=${author}" fi echo -e "\thour\tsum" - + local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}") local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}") for i in $(seq -w 0 23) @@ -633,7 +635,7 @@ if [[ "$#" -eq 1 ]]; then -r|--suggest-reviewers) suggestReviewers;; -T|--detailed-git-stats) detailedGitStats;; -R|--git-stats-by-branch) - branch="" + branch="${_GIT_BRANCH:-}" while [[ -z "${branch}" ]]; do read -r -p "Which branch? " branch done diff --git a/git-quick-stats.1 b/git-quick-stats.1 index 65e6d75..5215a49 100644 --- a/git-quick-stats.1 +++ b/git-quick-stats.1 @@ -1,13 +1,13 @@ .TH git-quick-stats "1" "January 2020" "git-quick-stats" "User Commands" .SH NAME -.B git\-quick\-stats +.B git\-quick\-stats \- Simple and efficient way to access various stats in a git repository. .SH SYNOPSIS .PP -For non\-interactive mode: +For non\-interactive mode: .B git\-quick\-stats [OPTIONS] .PP -For interactive mode: +For interactive mode: .B git-quick-stats .PP .SH DESCRIPTION @@ -131,6 +131,10 @@ You can also set _GIT_MERGE_VIEW to only show merge commits, example: You can switch to the legacy color scheme, example: .PP .B export _MENU_THEME=legacy +.PP +You can set _GIT_BRANCH to set the branch of the stats, example: +.PP +.B export _GIT_BRANCH="master" . .fi diff --git a/tests/commands_test.sh b/tests/commands_test.sh index 57e143f..d961090 100755 --- a/tests/commands_test.sh +++ b/tests/commands_test.sh @@ -69,7 +69,9 @@ ADDITIONAL USAGE You can also set _GIT_MERGE_VIEW to only show merge commits ex: export _GIT_MERGE_VIEW=exclusive You can set _MENU_THEME to display the legacy color scheme - ex: export _MENU_THEME=legacy" + ex: export _MENU_THEME=legacy + You can set _GIT_BRANCH to set the branch of the stats + ex: export _GIT_BRANCH=master" assert_raises "$src fail" 1