50 lines
836 B
Bash
Executable file
50 lines
836 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
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
|