Compare commits

..

8 Commits

Author SHA1 Message Date
arzzen
3f0befcd07 fix shortlog filter 2021-04-02 13:34:46 +02:00
Lukáš Mešťan
292876846d Merge pull request #124 from tomice/master
Fix escape sequences when outputting to non-TTYs
2021-03-31 17:31:28 +02:00
Tom Ice
e70c288225 Fix escape sequences when outputting to non-TTYs
* When performing actions such as redirecting the stats to a file,
  the terminal escape sequences for handling colors gets added
  to the top message in the text file. While running commands such
  as sed can fix this, it is inconvenient for users wishing to redirect
  or pipe the stats in a clean way.

  Attempting to use test -t yielded some unexpected results, as well
  as extra logic for handling a non-tty case, so for now, we are
  simply removing the colors from the message so it defaults to
  standard terminal colors and formatting

Fixes #122
2021-03-31 10:33:25 -04:00
Lukáš Mešťan
4d2621b084 Update LICENSE
bump year
2021-02-24 08:14:12 +01:00
Lukáš Mešťan
2318d42765 Merge pull request #121 from tomice/master
Change default date to be when git was first invented
2021-02-05 17:02:54 +01:00
Tom Ice
ef74d79102 Change default date to be when git was first invented
* The current default date is set to UNIX Epoch time. However, it seems
  some people are possibly having issues with date/time formats within
  their OSes. This commit attempts to fix issue #115 when the default
  date may be too old and cause no output to show
2021-01-29 19:31:29 -05:00
Lukáš Mešťan
82f8690285 Merge pull request #120 from vutny/fix-tests-assert-contains
test: fix assert_contains and its invocation
2020-12-19 19:55:30 +01:00
Denys Havrysh
0f641ea0e6 test: fix assert_contains and its invocation 2020-12-18 17:27:46 +02:00
4 changed files with 24 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Lukáš Mešťan
Copyright (c) 2021 Lukáš Mešťan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -14,7 +14,7 @@ _since=${_GIT_SINCE:-}
if [[ -n "${_since}" ]]; then
_since="--since=$_since"
else
_since="--since=1970-01-01"
_since="--since=2005-04-07"
fi
# End of git log date. Respects all git datetime formats
@@ -224,12 +224,9 @@ showMenu() {
# OUTS: None
################################################################################
function optionPicked() {
local -r bold=$(tput bold)
local -r red=$(tput setaf 1)
local -r reset=$(tput sgr0)
local msg=${*:-"${reset}Error: No message passed"}
local msg=${*:-"Error: No message passed"}
echo -e "${bold}${red}${msg}${reset}\n"
echo -e "${msg}\n"
}
################################################################################
@@ -380,11 +377,13 @@ function jsonOutput() {
function commitsByMonth() {
optionPicked "Git commits by month:"
echo -e "\tmonth\tsum"
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
for i in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
do
echo -en "\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
"$_since" "$_until" $_log_options | grep " $i " | wc -l
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep " $i " | wc -l
done | awk '{
count[$1] = $2
total += $2
@@ -411,12 +410,14 @@ function commitsByMonth() {
function commitsByWeekday() {
optionPicked "Git commits by weekday:"
echo -e "\tday\tsum"
local startYear=$(echo "$_since" | grep -Eo "[0-9]{4}")
local endYear=$(echo "$_until" | grep -Eo "[0-9]{4}")
local counter=1
for i in Mon Tue Wed Thu Fri Sat Sun
do
echo -en "\t$counter\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
"$_since" "$_until" $_log_options | grep "$i " | wc -l
"$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep "$i " | wc -l
counter=$((counter+1))
done | awk '{
}
@@ -456,11 +457,14 @@ 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)
do
echo -ne "\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
"${_author}" "$_since" "$_until" $_log_options | grep ' '$i: | wc -l
"${_author}" "$_since" "$_until" $_log_options | grep -E "($startYear|$endYear)" | grep ' '$i: | wc -l
done | awk '{
count[$1] = $2
total += $2

View File

@@ -17,12 +17,16 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o nounset
export DISCOVERONLY=${DISCOVERONLY:-}
export DEBUG=${DEBUG:-}
export STOP=${STOP:-}
export INVARIANT=${INVARIANT:-}
export CONTINUE=${CONTINUE:-}
GREP=${GREP:-grep}
args="$(getopt -n "$0" -l \
verbose,help,stop,discover,invariant,continue vhxdic $*)" \
|| exit -1
@@ -132,12 +136,12 @@ assert_raises() {
_assert_with_grep() {
local grep_modifier="$1"
local output="$($2)"
local exitcode="$4" || 0
local exitcode=0
shift 2
while [ $# != 0 ]; do
assert_raises "echo '$output' | $GREP $grep_modifier '$1'" $exitcode || return 1
shift
assert_raises "echo '$output' | $GREP $grep_modifier '$1'" $exitcode || return 1
shift
done
}

View File

@@ -73,13 +73,13 @@ ADDITIONAL USAGE
assert_raises "$src fail" 1
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)" 127
assert_contains "$src --suggest-reviewers" "Suggested code reviewers (based on git history)"
assert_raises "$src --suggest-reviewers" 0
assert_contains "$src --detailed-git-stats" "Contribution stats" 127
assert_contains "$src --detailed-git-stats" "Contribution stats"
assert_raises "$src --detailed-git-stats" 0
assert_contains "$src --commits-per-day" "Git commits per date" 127
assert_contains "$src --commits-per-day" "Git commits per date"
assert_raises "$src --commits-per-day" 0
assert_end