ftest/tests/git_cmd_init.sh

47 lines
709 B
Bash
Raw Normal View History

2023-09-27 17:18:41 +05:30
#!/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