summaryrefslogtreecommitdiff
path: root/test/create_empty_commits.sh
blob: 6f6a7f8b924cd25e40e8949ff8e0bd929da6992b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

. ./scorsh_functions

LINE_FILE=.line_file
cd ${SCORSH_APP}
LAST_LINE=$(wc -l scorsh.log | cut -d " " -f 1)
echo ${LAST_LINE} > ${LINE_FILE}
cd - > /dev/null

### create an empty git commit without a scorsh-command the first
### commit will be ignored by scorsh for the moment, due to an error
### on the 0000...0000 oid
cd ${LOCAL_REPO}
git commit --allow-empty -m "this is an empty commit"
check "[ $? -eq 0 ]" $0 "create_first_commit"

LAST_LINE=$(cat ${SCORSH_APP}/${LINE_FILE})
git push

cd - > /dev/null

cd ${SCORSH_APP}
ret=$(tail -n +${LAST_LINE} scorsh.log | grep -c "Invalid commit ID")
sleep 1
LAST_LINE=$(wc -l scorsh.log | cut -d " " -f 1)
echo ${LAST_LINE} > ${LINE_FILE}
cd - > /dev/null

check "[ \"$ret\" = \"2\" ] " $0 "check_first_commit"

### create two more commits without scorsh-commands
cd ${LOCAL_REPO}
git commit --allow-empty -m "second commit"
check "[ $? -eq 0 ]" $0 "create_second_commit"
git commit --allow-empty -m "third commit"
check "[ $? -eq 0 ]" $0 "create_third_commit"

LAST_LINE=$(cat ${SCORSH_APP}/${LINE_FILE})
commits=$(git log | grep "^commit " | cut -d " " -f 2 | head -2)
message_id=$(git push | grep "remote: id:" | cut -d " " -f 3)
cd - > /dev/null

cd ${SCORSH_APP}
sleep 1
for c in ${commits}; do
    ret=$(tail -n +${LAST_LINE} scorsh.log | grep -c "error parsing commit ${c}: no SCORSH message found")
    check "[ \"$ret\" = \"2\" ]" $0 "process_empty_commit"
done

LAST_LINE=$(wc -l scorsh.log | cut -d " " -f 1)
echo ${LAST_LINE} > ${LINE_FILE}
cd - > /dev/null


##check_fatal "[ 1 -eq 0 ]" $0 "abort_on_purpose"

rm ${LINE_FILE}

return_results