Guest User

Untitled

a guest
Oct 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. CHINACHU_DIR='/home/tao/Chinachu/data/'
  4.  
  5. cd $CHINACHU_DIR
  6.  
  7. titleRow=`git diff | grep '^-' | grep '"title"' | sed -e 's/-\s*"title":\s*"//' -e 's/",$//'`
  8. endDateRow=`git diff | grep '^-' | grep '"end"' | sed -e 's/-\s*"end":\s*//' -e 's/000,$//'`
  9.  
  10. if [ "`echo $titleRow`" == "" ]; then
  11. echo "You DID NOT delete recorded file?"
  12. exit 1;
  13. fi
  14.  
  15. titleRowCount=`echo $titleRow | wc -l`
  16.  
  17. if [ "`echo $titleRowCount`" -ne 1 ]; then
  18. echo "You DID NOT deleted 1 recorded items?"
  19. echo "Please manual commit"
  20. echo ""
  21. echo $titleRow
  22. exit 1;
  23. fi
  24.  
  25. if [ "`date +"%Y"`" -eq "`date -d @$endDateRow +"%Y"`" ]; then
  26. commitMsg="delete `date -d @$endDateRow +"%m/%d"` $titleRow"
  27. else
  28. commitMsg="delete `date -d @$endDateRow +"%Y/%m/%d"` $titleRow"
  29. fi
  30.  
  31. echo $commitMsg
  32. echo "OK?"
  33. read input
  34. if [ "`echo $input`" == "OK" -o "`echo $input`" == "ok" -o "`echo $input`" == "y" ]; then
  35. git add recorded.json
  36. git commit -m "$commitMsg"
  37. git push
  38. else
  39. echo "cancel"
  40. fi
  41.  
  42. exit 0;
Add Comment
Please, Sign In to add comment