ftest/tests/git_cmd_init.sh

46 lines
709 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
readonly DIR=/tmp/git_cmd_init_tmp
readonly REPO=$DIR/repo
commit() {
git add --all
git commit \
--author="ftest-test-util-script <ftest-test-util-script@example.org>" \
--message="$1"
}
write_commits_to_file() {
pushd $REPO
popd
rm -rf $DIR/commits
git log --pretty=oneline | cut -d ' ' -f 1 > $DIR/commits
}
init() {
rm -rf $DIR || true
mkdir -p $REPO
cd $REPO
git init
echo "foo" > 1_commit.txt
commit "first commit"
echo "bar" > 2_commit.txt
commit "second commit"
write_commits_to_file
}
update() {
cd $REPO
echo "bar" >> 3_commit.txt
commit "new commit"
write_commits_to_file
}
$@
exit 0