Yay Scripting!
Instructions to get started
1. cd ~/Desktop
2. mkdir scripts
3. cd scripts
4. touch git_checkoutStatus.sh
5. chmod a+rwx git_checkoutStatus.sh
6. ls -l (or ll)
Instructions to get started (con't)
7. Open directory in atom (atom .)
8. open git_checkoutStatus.sh in atom
9. copy/paste the slack script into git_checkoutStatus.sh
10. save the file git_checkoutStatus.sh
Switch back over to iterm and make sure that you are still in ~/Desktop/scripts
Instructions to get started (con't)
11. ./git_checkoutStatus.sh
You have a working bash script,
but what does it do?
#!/bin/bash
cd ~/galvanize/assessments/
dirArray=(*/)
echo " ">~/Desktop/scripts/Daily_Assessment_Status.txt
echo "======git status=====">>~/Desktop/scripts/Daily_Assessment_Status.txt
date >> ~/Desktop/scripts/Daily_Assessment_Status.txt
echo "===================">>~/Desktop/scripts/Daily_Assessment_Status.txt
echo " ">>~/Desktop/scripts/Daily_Assessment_Status.txt
echo " ">>~/Desktop/scripts/Daily_Assessment_Status.txt
for ((i=0; i<${#dirArray[@]}; i++)); do
<insert some stuff to do here>
done
if test -d ${dirArray[$i]}/.git/
then
<insert some stuff to do here>
fi
git status -s
==== g48_js-accumulator-assessment/ ===
M README.md
M src/every.js
?? nodehelp.js
==========================
echo '====' ${dirArray[$i]} '==='>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ${dirArray[$i]}
git status -s>>~/Desktop/scripts/Daily_Assessment_Status.txt
git log --stat origin/master..HEAD>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo '=========================='>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ~/galvanize/assessments/
Understanding git status -s
? ? wingding.md
MM README.md
M README.md
The second is for the working directory
' ' = unmodified
M = modified
A = added, D = deleted, R = renamed, C = copied, U = updated but unmerged, !! = ignored files
Understanding git status -s
? ? wingding.md
MM README.md
M README.md
git status log
==== g48_big-o-assessment/ ===
commit 15ca9bc205896149e480c181777e15352cc96513
.......
==========================
echo '====' ${dirArray[$i]} '==='>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ${dirArray[$i]}
git status -s>>~/Desktop/scripts/Daily_Assessment_Status.txt
git log --stat origin/master..HEAD>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo '=========================='>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ~/galvanize/assessments/
Now lets look at that OUTPUT file.
Daily_Assessment_Status.txt
Daily_Assessment_Status.txt
echo " ">~/Desktop/scripts/Daily_Assessment_Status.txt
echo "======git status=====">>~/Desktop/scripts/Daily_Assessment_Status.txt
date >> ~/Desktop/scripts/Daily_Assessment_Status.txt
echo "=====================">>~/Desktop/scripts/Daily_Assessment_Status.txt
echo " ">>~/Desktop/scripts/Daily_Assessment_Status.txt
echo " ">>~/Desktop/scripts/Daily_Assessment_Status.txt
---space
======git status=====
Thu Feb 23 20:53:46 PST 2017
=====================
---space
---space
Becomes
---->
Daily_Assessment_Status.txt
echo '====' ${dirArray[$i]} '==='>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ${dirArray[$i]}
git status -s>>~/Desktop/scripts/Daily_Assessment_Status.txt
git log --stat origin/master..HEAD>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo '=========================='>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
echo ' '>>~/Desktop/scripts/Daily_Assessment_Status.txt
cd ~/galvanize/assessments/
==== g48_js-accumulator-assessment/ ===
M README.md
M src/every.js
?? nodehelp.js
==========================
Be like this guy^
Hint: it makes your life easier