Skip to content

Instantly share code, notes, and snippets.

@gion-pop
Created December 19, 2017 19:32
Show Gist options
  • Save gion-pop/ebf64869c48798fa6f794550b9ca8dc1 to your computer and use it in GitHub Desktop.
Save gion-pop/ebf64869c48798fa6f794550b9ca8dc1 to your computer and use it in GitHub Desktop.
commit id を付加してコピー
#!/bin/bash
dpath=$(dirname $1)
cd $dpath
if git rev-parse 2> /dev/null; then
commit_id=$(git show -s --format=%H)
commit_id=${commit_id:0:7}
src=$(basename $1)
fname=${src%.*}
ext=${src##*.}
destname=${fname}.${commit_id}.${ext}
if [ "$2" = "" ]; then
dest=${destname}
else
dest=$2/${destname}
fi
cp -r ${src} ${dest}
echo "${src} -> ${dest}"
else
echo "Not a git repository."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment