Guest User

Untitled

a guest
Jun 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #!/bin/bash
  2. echo "Export Git Diff"
  3.  
  4. read -p "Export Start Commit ID: " input1
  5. read -p "Export End Commit ID: " input2
  6.  
  7. commitIdStart="${input1}"
  8. if [ "${input2}" == "" ]; then
  9. commitIdEnd="HEAD"
  10. else
  11. commitIdEnd="${input2}"
  12. fi
  13.  
  14. echo "Start ID: $commitIdStart"
  15. echo "End ID: $commitIdEnd"
  16.  
  17. #Create Export Folder
  18. now=$(date +%Y%m%d_%H%M%S)
  19. #echo "Current date: $now"
  20. dirpath="GitExport/$now"
  21. echo "Export Path:$dirpath"
  22. mkdir -p $dirpath
  23.  
  24.  
  25. #Get File List
  26. files=$(git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $commitIdStart $commitIdEnd);
  27. #echo $files;
  28.  
  29. for item in $files ; do
  30. echo "Copy: $item"
  31. ## For Linux (Todo Test)
  32. newdir=$(dirname $item)
  33. mkdir -p "$dirpath/$newdir"
  34. cp "$item" "$dirpath/$item"
  35. # For Mac OS
  36. # ditto "$item" "$dirpath/$item"
  37. done
Add Comment
Please, Sign In to add comment