Skip to content

Commit 0772cbf

Browse files
committed
Update git-sisters-update.ps1 with exit echos
1 parent ef154d7 commit 0772cbf

File tree

1 file changed

+51
-33
lines changed

1 file changed

+51
-33
lines changed

git-sisters-update.ps1

100755100644
Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# TODO: Add handling of script call attribute containing REPONAME and GITHUB_USER:
1919
$GITHUB_USERID="wilson-jetbloom" # <-- replace with your own
2020

21-
# Sample call in MacOS running PowerShell for Mac:
21+
# Sample call in MacOS running PowerShell for Mac:
2222
# chmod +x git-sisters-update.ps1
2323
# ./git-sisters-update.ps1
2424
# results in "Add " as branch name. Alternately, run script with your own branch:
@@ -28,7 +28,7 @@
2828
# http://skimfeed.com/blog/windows-command-prompt-ls-equivalent-dir/
2929

3030

31-
# PS TRICK: Functions must be defined at the top of the script.
31+
# PS TRICK: Functions must be defined at the top of the script.
3232
function sisters_new_photo-info
3333
{
3434
# sisters_new_photo-info 1979 "Bloomfield, Connecticut"
@@ -53,7 +53,7 @@ function sisters_new_photo-info
5353

5454
function sisters_new_meta_file
5555
{
56-
# TODO:
56+
# TODO:
5757
$PERSON_NAME = $args[0]
5858
$FILE_CONTEXT = $args[0].ToLower() + ".md" # file name
5959

@@ -65,9 +65,9 @@ function sisters_new_meta_file
6565
New-Item $FILE_CONTEXT >$null
6666

6767
$NL = "`n" # New Line $s, $t -join ", "
68-
$OUT_STRING = "# $PERSON_NAME" +$NL
68+
$OUT_STRING = "# $PERSON_NAME" +$NL
6969
$OUT_STRING += $NL
70-
# PROTIP: Double grave-accent(`) to use back-tick as regular text:
70+
# PROTIP: Double grave-accent(`) to use back-tick as regular text:
7171
$OUT_STRING += "**Smiling:** ``$SMILING``" +$NL
7272
$OUT_STRING += $NL
7373
$OUT_STRING += "**Outfit:** $CLOTHING"
@@ -86,10 +86,10 @@ function sisters_replace_meta_file
8686

8787
echo "******** processing $FILE_CONTEXT :"
8888
#$SMILING = $args[1] # smiling true or false
89-
#$CLOTHING = $args[2]
89+
#$CLOTHING = $args[2]
9090

9191
# Get-Content info: https://technet.microsoft.com/en-us/library/ee176843.aspx
92-
$WORK_TEXT = Get-Content $FILE_CONTEXT
92+
$WORK_TEXT = Get-Content $FILE_CONTEXT
9393
#cat $WORK_TEXT
9494

9595
# About regex in PowerShell: https://www.youtube.com/watch?v=K3JKmWmbbGM
@@ -105,7 +105,7 @@ function sisters_replace_meta_file
105105
# Set-Content info: https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.management/Set-Content?f=255&MSPPError=-2147217396
106106

107107
# PROTIP: Use https://regex101.com/ using Flavor: PY (python) to verify:
108-
# Put slashes in front of special characters used as regular text:
108+
# Put slashes in front of special characters used as regular text:
109109

110110
echo "******** cat $FILE_CONTEXT : AFTER changes :"
111111
cat $FILE_CONTEXT
@@ -137,7 +137,7 @@ $NOW = Get-Date -Format "yyyy-MM-ddTHH:mmzzz"
137137
echo "******** PSSCRIPTROOT= $PSSCRIPTROOT"
138138
git --version
139139

140-
# exit #1
140+
# exit #1
141141

142142
$REPONAME='sisters'
143143
$UPSTREAM="https://github.com/hotwilson/sisters" # a repo prepared for the class.
@@ -147,9 +147,9 @@ $NOW = Get-Date -Format "yyyy-MM-ddTHH:mmzzz"
147147
$FileExists = Test-Path $REPONAME
148148
if ($FileExists -eq $True ){
149149
# See https://technet.microsoft.com/en-ca/library/hh849765.aspx?f=255&MSPPError=-2147217396
150-
Remove-Item -path ${REPONAME} -Recurse -Force # instead of rm -rf ${REPONAME}
150+
Remove-Item -path ${REPONAME} -Recurse -Force # instead of rm -rf ${REPONAME}
151151
}
152-
152+
echo "******** Exit #2."
153153
# exit #2
154154

155155
# New-item ${REPONAME} -ItemType "directory" >$null # instead of mkdir ${REPONAME}
@@ -161,14 +161,15 @@ if ($FileExists -eq $True ){
161161
# Notice the string concatenation format:
162162
git clone "$($GITHUB_REPO).git" # $REPONAME # --depth=1
163163

164-
echo "******** git tag -l cloned # lightweight tag for private temp use :"
164+
echo "******** git tag -l cloned # lightweight tag for private temp use :"
165165
git tag -l cloned
166166
# Note no spaces and thus no quotes.
167-
echo "******** git tag (list) :"
167+
echo "******** git tag (list) :"
168168
git tag
169-
echo "******** git log :"
169+
echo "******** git log :"
170170
git l -3
171171

172+
echo "******** Exit #3."
172173
# exit #3
173174

174175
echo "******** Ensure $REPONAME folder is specified in .gitignore file:"
@@ -184,6 +185,7 @@ git tag
184185
echo "******** ${REPONAME} added to bottom of .gitignore file."
185186
}
186187

188+
echo "******** Exit #4."
187189
# exit #4
188190

189191

@@ -202,21 +204,23 @@ $CurrentDir = $(get-location).Path;
202204
echo "******** Run PowerShell file for Git configurations at the repo level:"
203205
# PS TRICK: Get parent folder path using the $MyInvocation built-in PS variable:
204206
# See http://stackoverflow.com/questions/7377981/how-do-i-call-another-powershell-script-with-a-relative-path
205-
$ScriptPath = Split-Path -Parent $MyInvocation.InvocationName
207+
$ScriptPath = Split-Path -Parent $MyInvocation.InvocationName
206208
$UtilPath = Join-Path -Path $ScriptPath -ChildPath ..\
207-
#Write-Host "Path:" $UtilPath
209+
#Write-Host "Path:" $UtilPath
208210
# NOTE: PowerShell accepts both forward and backward slashes:
209211
& "$UtilPath/git-client-config.ps1"
210-
# Alternately, use & to run scripts in same scope:
212+
# Alternately, use & to run scripts in same scope:
211213
# & "../git_client-config.ps1 global" #
212-
# Alternately, use . to run scripts in child scope that will be thrown away:
214+
# Alternately, use . to run scripts in child scope that will be thrown away:
213215
# . "../git_client-config.ps1 global" #
214216
#echo "******** Present Working Directory :"
215217
#pwd
218+
219+
echo "******** Exit #6."
216220
# exit #6
217221

218222
Write-Host "******** git remote add upstream $UPSTREAM :"
219-
git remote add upstream ${UPSTREAM}
223+
git remote add upstream ${UPSTREAM}
220224
Write-Host "******** git remote -v :"
221225
git remote -v
222226
Write-Host "******** git remote show origin :"
@@ -225,10 +229,12 @@ git remote add upstream ${UPSTREAM}
225229
echo "******** cat .git/HEAD to show internal current branch HEAD :"
226230
# The contents of HEAD is stored in this file:
227231
cat .git/HEAD
228-
232+
229233
echo "******** git branch -avv at master:"
230234
git branch -avv # shows tracking branches
231-
# In Merge lesson, change hotwilson GitHub at this point and git merge
235+
# In Merge lesson, change hotwilson GitHub at this point and git merge
236+
237+
echo "******** Exit #7."
232238
# exit #7
233239

234240
echo "******** git l = git log of commits in repo:"
@@ -240,7 +246,7 @@ git branch -avv # shows tracking branches
240246
dir
241247
}else{ # Mac / Linux:
242248
ls # -al
243-
}
249+
}
244250
#tree
245251
echo "******** git reflog (showing only what occurred locally):"
246252
git reflog
@@ -250,27 +256,30 @@ git branch -avv # shows tracking branches
250256
echo "******** git status at initial clone:"
251257
git status
252258

259+
echo "******** Exit #8."
253260
# exit #8
254261

255262
echo "******** cat ${REPONAME}/bebe.md at HEAD:"
256263
cat bebe.md
257264

258265
echo "******** git blame bebe.md : "
259266
git blame bebe.md
260-
# NOTE:
267+
# NOTE:
261268
echo "******** git l = git log of commits in repo:"
262269
# add -10 to list 10 lines using l for log alias:
263270
git l -10
264271
# Notice the title "BeBe" and blank lines in the file are from the initial commit.
265272
# Two lines were changed in the latest commit.
266273

274+
echo "******** Exit #9."
267275
# exit #9
268276

269277
# echo "******** git show --oneline --abbrev-commit - press q to quit:"
270278
# git show --oneline --abbrev-commit
271279

272280
git diff HEAD..HEAD^
273281

282+
echo "******** Exit #10."
274283
# exit #10
275284

276285
# echo "******** Begin trace :"
@@ -285,14 +294,15 @@ git checkout master
285294
$CURRENT_BRANCH="feature1"
286295
}else{
287296
$CURRENT_BRANCH=$args[0]
288-
}
297+
}
289298
echo "******** git checkout new branch ""$CURRENT_BRANCH"" from master branch :"
290-
git checkout -b $CURRENT_BRANCH
299+
git checkout -b $CURRENT_BRANCH
291300
git branch -avv
292-
# PS TRICK: Double-quotes to display words in quotes:
301+
# PS TRICK: Double-quotes to display words in quotes:
293302
echo "******** git reflog at ""$CURRENT_BRANCH"" :"
294303
git reflog
295304

305+
echo "******** Exit #11."
296306
# exit #11
297307

298308
$CURRENT_YEAR = "1979"
@@ -302,6 +312,7 @@ sisters_new_photo-info $CURRENT_YEAR "Hartford, Connecticut"
302312
#sisters_new_meta_file BeBe false "White buttoned shirt"
303313
# Notice the person name is upper/lower case:
304314

315+
echo "******** Exit #12."
305316
# exit #12
306317

307318
echo "******** git checkout ""@{10 minutes ago}"" :"
@@ -313,12 +324,14 @@ sisters_new_meta_file Bebe false "White buttoned shirt"
313324
# echo "******** git add -p (hunks interactive) :"
314325
#git add -p # GUI (requires manual response)
315326

327+
echo "******** Exit #13."
316328
exit #13
317329

318330
sisters_new_meta_file Heather true "Plaid shirt"
319331
sisters_new_meta_file Laurie false "Cable-knit sweater"
320332
sisters_new_meta_file Mimi false "French sailor shirt"
321333

334+
echo "******** Exit #14."
322335
# exit #14
323336

324337
echo "******** git stash :"
@@ -333,6 +346,7 @@ git stash list
333346
echo "******** git status (after git stash) :"
334347
git status
335348

349+
echo "******** Exit #15."
336350
# exit #15
337351

338352
# Do something else
@@ -341,7 +355,8 @@ git stash list
341355
git stash pop
342356
echo "******** git status : before git add :"
343357
git status
344-
358+
359+
echo "******** Exit #16."
345360
# exit #16
346361

347362
echo "******** git add . :"
@@ -367,6 +382,7 @@ git commit -m"Snapshot for $CURRENT_YEAR"
367382
echo "******** git l = git log of commits in repo:"
368383
git l
369384

385+
echo "******** Exit #17."
370386
exit #17 --- major checkpoint here.
371387

372388
# Export an entire branch, complete with history, to the specified file:
@@ -382,15 +398,17 @@ exit #17 --- major checkpoint here.
382398
}else{ # Mac / Linux:
383399
git archive $CURRENT_BRANCH --format=tar --output=$REPONAME_$CURRENT_BRANCH_$REPONAME.tar
384400
}
385-
}
401+
}
386402
# list files archived.
387403

404+
echo "******** Exit #18."
388405
exit #18
389406

390407

391408
#git push --dry-run
392409

393410

411+
echo "******** Exit #20."
394412
exit #19
395413
#exit #20 reserved
396414

@@ -410,6 +428,7 @@ git checkout $CURRENT_COMMIT
410428
echo "******** git log at $CURRENT_BRANCH :"
411429
git commit
412430

431+
echo "******** Exit #21."
413432
exit #21
414433

415434
$CURRENT_COMMIT="a874ef4"
@@ -420,6 +439,7 @@ git reset --soft $CURRENT_COMMIT
420439
echo "******** git reflog at $CURRENT_BRANCH :"
421440
git reflog
422441

442+
echo "******** Exit #22."
423443
exit #22
424444

425445
echo "******** Make changes to files and stage it at $CURRENT_COMMIT :"
@@ -430,6 +450,7 @@ git reset HEAD
430450
echo "******** git fsck after $CURRENT_COMMIT :"
431451
git fsck
432452

453+
echo "******** Exit #23."
433454
exit #23
434455

435456
$CURRENT_COMMIT="82e957c"
@@ -439,12 +460,9 @@ git reset --hard $CURRENT_COMMIT
439460
git fsck
440461

441462

442-
exit #23
443-
444-
echo "******** $NOW ends."
445-
463+
echo "******** Exit #24. $NOW ends."
446464
exit #24
447465

448466
##############################
449467

450-
# END OF FILE
468+
# END OF FILE

0 commit comments

Comments
 (0)