Skip to content

Instantly share code, notes, and snippets.

@ixqbar
Created February 14, 2017 06:45
Show Gist options
  • Save ixqbar/b51370cd63160b0d3e767608c1b5f165 to your computer and use it in GitHub Desktop.
Save ixqbar/b51370cd63160b0d3e767608c1b5f165 to your computer and use it in GitHub Desktop.
版本控制

#!/bin/sh 
if ! test -f last_version.log; then 
    echo "not found last_version.log" 
    exit 1 
fi 

found_changes=0 
last_version=`tail -n 1 last_version.log` 
for file in `git diff ${last_version} HEAD --name-only --diff-filter=ACM`; do 
    if test -f $file; then 
        found_changes=$(( found_changes + 1 )) 
        echo $file 
    fi 
done; 

if test $found_changes -gt 0; then 
    git log --pretty=oneline | awk -F " " '{print $1}' | head -n 1 >> last_version.log 
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment