From bdfe3beb25b93aef8ed44ba7671e7e3edde88bb1 Mon Sep 17 00:00:00 2001 From: Tom Ice Date: Sun, 12 May 2019 19:32:11 -0400 Subject: [PATCH] New default theme with toggle-able legacy theme * This sets the newly proposed theme as the main theme. In order to switch back to the legacy theme, set _MENU_THEME to legacy. This feature is currently an experimental feature and may change in the future. * Fixes documentation and updates test to reflect newly changed theme. --- README.md | 4 +-- git-quick-stats | 59 ++++++++++++++++++++++-------------------- git-quick-stats.1 | 4 +-- tests/commands_test.sh | 2 +- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index e000b02..b38d8a5 100644 --- a/README.md +++ b/README.md @@ -117,10 +117,10 @@ export _GIT_PATHSPEC=':!directory' #### Color themes -You can change to an alternative color scheme by toggling the variable `_MENU_THEME` between `default` and `alternative` +You can change to the legacy color scheme by toggling the variable `_MENU_THEME` between `default` and `legacy` ```bash -export _MENU_THEME=alternative +export _MENU_THEME=legacy ``` ## Installation diff --git a/git-quick-stats b/git-quick-stats index 52a878c..3f2c406 100755 --- a/git-quick-stats +++ b/git-quick-stats @@ -25,7 +25,7 @@ else fi # Default menu theme -# Set an alternative by typing "export _MENU_THEME=alternative" +# Set the legacy theme by typing "export _MENU_THEME=legacy" _theme="${_MENU_THEME:=default}" ################################################################################ @@ -116,8 +116,8 @@ ADDITIONAL USAGE ex: export _GIT_LIMIT=20 You can exclude a directory from the stats by using pathspec ex: export _GIT_PATHSPEC=':!directory' - You can set _MENU_THEME to display an alternative color scheme - ex: export _MENU_THEME=alternative" + You can set _MENU_THEME to display the legacy color scheme + ex: export _MENU_THEME=legacy" } ################################################################################ @@ -136,39 +136,42 @@ function show_menu() { local text="" local nums="" local help_txt="" + local exit_txt="" # Adjustable color menu option - if [[ "${_theme}" == "alternative" ]]; then - titles="${bold}${cyan}" - text="${normal}${white}" - nums="${bold}${white}" - help_txt="${cyan}" - else + if [[ "${_theme}" == "legacy" ]]; then titles="${bold}${red}" text="${normal}${cyan}" nums="${bold}${yellow}" - help_txt="${white}" + help_txt="${normal}${yellow}" + exit_txt="${bold}${red}" + else + titles="${bold}${cyan}" + text="${normal}${white}" + nums="${normal}${bold}${white}" + help_txt="${normal}${cyan}" + exit_txt="${bold}${cyan}" fi echo -e "\n${titles} Generate:${normal}" - echo -e "${nums} 1)${text} Contribution stats (by author)${normal}" - echo -e "${nums} 2)${text} Contribution stats (by author) on a specific branch${normal}" - echo -e "${nums} 3)${text} Git changelogs (last $_limit days)${normal}" - echo -e "${nums} 4)${text} Git changelogs by author${normal}" - echo -e "${nums} 5)${text} My daily status${normal}" - echo -e "\n${titles} List:${normal}" - echo -e "${nums} 6)${text} Branch tree view (last $_limit)${normal}" - echo -e "${nums} 7)${text} All branches (sorted by most recent commit)${normal}" - echo -e "${nums} 8)${text} All contributors (sorted by name)${normal}" - echo -e "${nums} 9)${text} Git commits per author${normal}" - echo -e "${nums} 10)${text} Git commits per date${normal}" - echo -e "${nums} 11)${text} Git commits per month${normal}" - echo -e "${nums} 12)${text} Git commits per weekday${normal}" - echo -e "${nums} 13)${text} Git commits per hour${normal}" - echo -e "${nums} 14)${text} Git commits by author per hour${normal}" - echo -e "\n${titles} Suggest${normal}:" - echo -e "${nums} 15)${text} Code reviewers (based on git history)${normal}" - echo -e "\n${help_txt}Please enter a menu option or ${bold}press Enter to exit.${normal}" + echo -e "${nums} 1)${text} Contribution stats (by author)" + echo -e "${nums} 2)${text} Contribution stats (by author) on a specific branch" + echo -e "${nums} 3)${text} Git changelogs (last $_limit days)" + echo -e "${nums} 4)${text} Git changelogs by author" + echo -e "${nums} 5)${text} My daily status" + echo -e "\n${titles} List:" + echo -e "${nums} 6)${text} Branch tree view (last $_limit)" + echo -e "${nums} 7)${text} All branches (sorted by most recent commit)" + echo -e "${nums} 8)${text} All contributors (sorted by name)" + echo -e "${nums} 9)${text} Git commits per author" + echo -e "${nums} 10)${text} Git commits per date" + echo -e "${nums} 11)${text} Git commits per month" + echo -e "${nums} 12)${text} Git commits per weekday" + echo -e "${nums} 13)${text} Git commits per hour" + echo -e "${nums} 14)${text} Git commits by author per hour" + echo -e "\n${titles} Suggest:" + echo -e "${nums} 15)${text} Code reviewers (based on git history)" + echo -e "\n${help_txt}Please enter a menu option or ${exit_txt}press Enter to exit." echo -n "${text}> ${normal}" read -r opt } diff --git a/git-quick-stats.1 b/git-quick-stats.1 index e39592f..4d8757a 100644 --- a/git-quick-stats.1 +++ b/git-quick-stats.1 @@ -113,9 +113,9 @@ You can exclude a directory from the stats by using pathspec, example: .PP .B export _GIT_PATHSPEC=':!directory' .PP -You can switch to an alternative color scheme, example: +You can switch to the legacy color scheme, example: .PP -.B export _MENU_THEME=alternative +.B export _MENU_THEME=legacy . .fi diff --git a/tests/commands_test.sh b/tests/commands_test.sh index 92c7314..6e380cc 100755 --- a/tests/commands_test.sh +++ b/tests/commands_test.sh @@ -4,7 +4,7 @@ src="./git-quick-stats" #assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n suggestReviewers - see best people to contact to review code\n detailedGitStats - displays a detailed list of git status\n commitsPerDay - displays a list of commits per day\n commitsByMonth - displays a list of commits per month\n commitsByWeekday - displays a list of commits per weekday\n commitsByHour - displays a list of commits per hour\n commitsByAuthorByHour - see a list of commits per hour by author\n commitsPerAuthor - displays a list of commits per author\n myDailyStats - see your current daily stats\n contributors - see a list of all contributors\n branchTree - see an ASCII graph of the git repo\n branchesByDate - show branches by date\n changelogs - see changelogs\n changelogsByAuthor - see changelogs by author\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=2017-20-01\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude a directory from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!directory'\n \nCONTRIBUTION\n For details regarding contribution, please see the contribution.md document\n\nLICENSE\n This is under the MIT license. See LICENSE in the repo for more info" -assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n -r, --suggest-reviewers\n show the best people to contact to review code\n -T, --detailed-git-stats\n give a detailed list of git stats\n -R, --git-stats-by-branch\n see detailed list of git stats by branch\n -d, --commits-per-day\n displays a list of commits per day\n -m, --commits-by-month\n displays a list of commits per month\n -w, --commits-by-weekday\n displays a list of commits per weekday\n -o, --commits-by-hour\n displays a list of commits per hour\n -A, --commits-by-author-by-hour\n displays a list of commits per hour by author\n -a, --commits-per-author\n displays a list of commits per author\n -S, --my-daily-stats\n see your current daily stats\n -C, --contributors\n see a list of everyone who contributed to the repo\n -b, --branch-tree\n show an ASCII graph of the git repo branch history\n -D, --branches-by-date\n show branches by date\n -c, --changelogs\n see changelogs\n -L, --changelogs-by-author\n see changelogs by author\n -h, -?, --help\n display this help text in the terminal\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=\"2017-20-01\"\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude a directory from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!directory'\n You can set _MENU_THEME to display an alternative color scheme\n ex: export _MENU_THEME=alternative" +assert "$src fail" "Invalid argument\n\nNAME\n git-quick-stats - Simple and efficient way to access various stats in a git repo\n\nSYNOPSIS\n For non-interactive mode: git-quick-stats [OPTIONS]\n For interactive mode: git-quick-stats\n\nDESCRIPTION\n Any git repository contains tons of information about commits, contributors,\n and files. Extracting this information is not always trivial, mostly because\n of a gadzillion options to a gadzillion git commands.\n\n This program allows you to see detailed information about a git repository.\n\nOPTIONS\n -r, --suggest-reviewers\n show the best people to contact to review code\n -T, --detailed-git-stats\n give a detailed list of git stats\n -R, --git-stats-by-branch\n see detailed list of git stats by branch\n -d, --commits-per-day\n displays a list of commits per day\n -m, --commits-by-month\n displays a list of commits per month\n -w, --commits-by-weekday\n displays a list of commits per weekday\n -o, --commits-by-hour\n displays a list of commits per hour\n -A, --commits-by-author-by-hour\n displays a list of commits per hour by author\n -a, --commits-per-author\n displays a list of commits per author\n -S, --my-daily-stats\n see your current daily stats\n -C, --contributors\n see a list of everyone who contributed to the repo\n -b, --branch-tree\n show an ASCII graph of the git repo branch history\n -D, --branches-by-date\n show branches by date\n -c, --changelogs\n see changelogs\n -L, --changelogs-by-author\n see changelogs by author\n -h, -?, --help\n display this help text in the terminal\n\nADDITIONAL USAGE\n You can set _GIT_SINCE and _GIT_UNTIL to limit the git time log\n ex: export _GIT_SINCE=\"2017-20-01\"\n You can set _GIT_LIMIT for limited output log\n ex: export _GIT_LIMIT=20\n You can exclude a directory from the stats by using pathspec\n ex: export _GIT_PATHSPEC=':!directory'\n You can set _MENU_THEME to display the legacy color scheme\n ex: export _MENU_THEME=legacy" assert_raises "$src fail" 1 assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" 127