Created
December 19, 2017 19:32
-
-
Save gion-pop/ebf64869c48798fa6f794550b9ca8dc1 to your computer and use it in GitHub Desktop.
commit id を付加してコピー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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