Skip to content

Commit 2d20ed6

Browse files
authored
fix: #52 - manage failure of git log command if no commits in repo (#53)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 89b1a2b commit 2d20ed6

File tree

5 files changed

+33
-8
lines changed

5 files changed

+33
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- [#32](https://github.com/Orange-OpenSource/floss-toolbox/issues/32) GitLab Auto Backup
88

9+
### Bugs
10+
11+
- [#52](https://github.com/Orange-OpenSource/floss-toolbox/issues/52) Failure of git log if no commits
12+
913
## Version 2.4.0
1014

1115
### Features

toolbox/diver/extract-emails-from-history.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Author: Pierre-Yves LAPERSONNE <pierreyves(dot)lapersonne(at)orange(dot)com> et al.
99

10-
# Version.............: 1.0.1
10+
# Version.............: 1.0.2
1111
# Since...............: 06/10/2021
1212
# Description.........: Using the Git history, provide a list of contributors
1313
#
@@ -22,7 +22,7 @@
2222

2323
set -euo pipefail
2424

25-
VERSION="1.0.1"
25+
VERSION="1.0.2"
2626
SCRIPT_NAME="extract-emails-from-history"
2727

2828
# -------------
@@ -216,6 +216,12 @@ fi
216216

217217
touch "$git_log_file"
218218

219+
if [ "$( git log --oneline -5 2>/dev/null | wc -l )" -eq 0 ]; then
220+
echo "Warning: Project '$git_based_project' is a git repository without any commit, that's weird"
221+
CleanFiles
222+
NormalExit
223+
fi
224+
219225
git log --since=$git_log_limit > $git_log_file
220226

221227
if [ ! -s "$git_log_file" ]; then

toolbox/diver/find-contributors-in-git-logs.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Author: Pierre-Yves LAPERSONNE <pierreyves(dot)lapersonne(at)orange(dot)com> et al.
99

10-
# Version.............: 1.2.0
10+
# Version.............: 1.2.1
1111
# Since...............: 11/05/2020
1212
# Description.........: Looks for words (defined in dedicated file) in git logs
1313
#
@@ -21,7 +21,7 @@
2121
#
2222

2323

24-
VERSION="1.2.0"
24+
VERSION="1.2.1"
2525
SCRIPT_NAME="find-contributors-in-git-logs"
2626

2727
# -------------
@@ -234,6 +234,11 @@ if [ -f $git_log_file ]; then
234234
rm $git_log_file
235235
fi
236236

237+
if [ "$( git log --oneline -5 2>/dev/null | wc -l )" -eq 0 ]; then
238+
echo "Warning: Project '$git_based_project' is a git repository without any commit, that's weird"
239+
NormalExit
240+
fi
241+
237242
git log --since=$git_log_limit > $git_log_file
238243

239244
if [ ! -s "$git_log_file" ]; then

toolbox/diver/find-missing-developers-in-git-commits.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Author: Pierre-Yves LAPERSONNE <pierreyves(dot)lapersonne(at)orange(dot)com> et al.
99

10-
# Version.............: 1.1.0
10+
# Version.............: 1.1.1
1111
# Since...............: 12/05/2020
1212
# Description.........: Looks in git commits in the DCO has been used, i.e. if commits have been signed off.
1313
# Checks also if commits authors are defined.
@@ -21,7 +21,7 @@
2121
# 3 - problem with a command
2222
#
2323

24-
VERSION="1.1.0"
24+
VERSION="1.1.1"
2525
SCRIPT_NAME="find-missing-developers-in-git-commits"
2626

2727
# -------------
@@ -199,6 +199,11 @@ if [ -f $git_log_file ]; then
199199
rm $git_log_file
200200
fi
201201

202+
if [ "$( git log --oneline -5 2>/dev/null | wc -l )" -eq 0 ]; then
203+
echo "Warning: Project '$git_based_project' is a git repository without any commit, that's weird"
204+
NormalExit
205+
fi
206+
202207
git log --since=$git_log_limit > $git_log_file
203208

204209
if [ ! -s "$git_log_file" ]; then

toolbox/diver/list-contributors-in-history.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Author: Pierre-Yves LAPERSONNE <pierreyves(dot)lapersonne(at)orange(dot)com> et al.
99

10-
# Version.............: 1.0.0
10+
# Version.............: 1.0.2
1111
# Since...............: 24/02/2022
1212
# Description.........: Using the Git history, provide a list of contributors' email addresses
1313
#
@@ -22,7 +22,7 @@
2222

2323
set -euo pipefail
2424

25-
VERSION="1.0.1"
25+
VERSION="1.0.2"
2626
SCRIPT_NAME="list-contributors-in-history"
2727

2828
# -------------
@@ -197,6 +197,11 @@ fi
197197

198198
touch "$git_log_file"
199199

200+
if [ "$( git log --oneline -5 2>/dev/null | wc -l )" -eq 0 ]; then
201+
echo "Warning: Project '$git_based_project' is a git repository without any commit, that's weird"
202+
NormalExit
203+
fi
204+
200205
git log --since=$git_log_limit > $git_log_file
201206

202207
if [ ! -s "$git_log_file" ]; then

0 commit comments

Comments
 (0)