Skip to content

Commit 999cfc4

Browse files
avargitster
authored andcommitted
test-lib functions: add --author support to test_commit
Add support for --author to "test_commit". This will simplify some current and future tests, one of those is being changed here. Let's also line-wrap the "git commit" command invocation to make diffs that add subsequent options easier to add, as they'll only need to add a new option line. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 76b8b8d commit 999cfc4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

t/t7509-commit-authorship.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ message_body () {
1818
}
1919

2020
test_expect_success '-C option copies authorship and message' '
21-
echo "Initial" >foo &&
22-
git add foo &&
23-
test_tick &&
24-
git commit -m "Initial Commit" --author Frigate\ \<[email protected]\> &&
25-
git tag Initial &&
21+
test_commit --author Frigate\ \<[email protected]\> \
22+
"Initial Commit" foo Initial Initial &&
2623
echo "Test 1" >>foo &&
2724
test_tick &&
2825
git commit -a -C Initial &&

t/test-lib-functions.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ debug () {
185185
# Do not call test_tick before making a commit
186186
# --signoff
187187
# Invoke "git commit" with --signoff
188+
# --author=<author>
189+
# Invoke "git commit" with --author=<author>
188190
#
189191
# This will commit a file with the given contents and the given commit
190192
# message, and tag the resulting commit with the given tag name.
@@ -193,6 +195,7 @@ debug () {
193195

194196
test_commit () {
195197
notick= &&
198+
author= &&
196199
signoff= &&
197200
indir= &&
198201
while test $# != 0
@@ -201,6 +204,10 @@ test_commit () {
201204
--notick)
202205
notick=yes
203206
;;
207+
--author)
208+
author="$2"
209+
shift
210+
;;
204211
--signoff)
205212
signoff="$1"
206213
;;
@@ -222,7 +229,9 @@ test_commit () {
222229
then
223230
test_tick
224231
fi &&
225-
git ${indir:+ -C "$indir"} commit $signoff -m "$1" &&
232+
git ${indir:+ -C "$indir"} commit \
233+
${author:+ --author "$author"} \
234+
$signoff -m "$1" &&
226235
git ${indir:+ -C "$indir"} tag "${4:-$1}"
227236
}
228237

0 commit comments

Comments
 (0)