Skip to content

Instantly share code, notes, and snippets.

@a9QrX3Lu
Last active July 7, 2021 02:29
Show Gist options
  • Select an option

  • Save a9QrX3Lu/865118896c70912cac4b38d87838f170 to your computer and use it in GitHub Desktop.

Select an option

Save a9QrX3Lu/865118896c70912cac4b38d87838f170 to your computer and use it in GitHub Desktop.
Save a copy of current output, which related to current git branch name, commit hash, system environment and time.
#!/usr/bin/env bash
repo=$(basename -s .git $(git config --get remote.origin.url))
tag=$(git name-rev --tags --name-only $(git rev-parse HEAD))
branch=$(git rev-parse --abbrev-ref HEAD)
timestamp=$(hostname)-$(uname -r)-$(date -I'seconds')
msg=$(git log -1 | cat)
DIR=~/testdata/${repo}/"${timestamp}-${branch}-${tag}"
# Create dir for the new test data
mkdir -p ${DIR}
for f in $@; do
cp $f ${DIR}/
done
# Save commit message as a file
echo ${msg} > ${DIR}/cmsg.txt
echo "Result is archived to ${DIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment