ftest/tests/git_cmd_init.sh

51 lines
836 B
Bash
Raw Normal View History

2023-09-27 17:18:41 +05:30
#!/bin/bash
2023-09-27 19:50:07 +05:30
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
2023-09-27 17:18:41 +05:30
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