18
18
# TODO: Add handling of script call attribute containing REPONAME and GITHUB_USER:
19
19
$GITHUB_USERID = " wilson-jetbloom" # <-- replace with your own
20
20
21
- # Sample call in MacOS running PowerShell for Mac:
21
+ # Sample call in MacOS running PowerShell for Mac:
22
22
# chmod +x git-sisters-update.ps1
23
23
# ./git-sisters-update.ps1
24
24
# results in "Add " as branch name. Alternately, run script with your own branch:
28
28
# http://skimfeed.com/blog/windows-command-prompt-ls-equivalent-dir/
29
29
30
30
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.
32
32
function sisters_new_photo-info
33
33
{
34
34
# sisters_new_photo-info 1979 "Bloomfield, Connecticut"
@@ -53,7 +53,7 @@ function sisters_new_photo-info
53
53
54
54
function sisters_new_meta_file
55
55
{
56
- # TODO:
56
+ # TODO:
57
57
$PERSON_NAME = $args [0 ]
58
58
$FILE_CONTEXT = $args [0 ].ToLower() + " .md" # file name
59
59
@@ -65,9 +65,9 @@ function sisters_new_meta_file
65
65
New-Item $FILE_CONTEXT > $null
66
66
67
67
$NL = " `n " # New Line $s, $t -join ", "
68
- $OUT_STRING = " # $PERSON_NAME " + $NL
68
+ $OUT_STRING = " # $PERSON_NAME " + $NL
69
69
$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:
71
71
$OUT_STRING += " **Smiling:** `` $SMILING `` " + $NL
72
72
$OUT_STRING += $NL
73
73
$OUT_STRING += " **Outfit:** $CLOTHING "
@@ -86,10 +86,10 @@ function sisters_replace_meta_file
86
86
87
87
echo " ******** processing $FILE_CONTEXT :"
88
88
# $SMILING = $args[1] # smiling true or false
89
- # $CLOTHING = $args[2]
89
+ # $CLOTHING = $args[2]
90
90
91
91
# 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
93
93
# cat $WORK_TEXT
94
94
95
95
# About regex in PowerShell: https://www.youtube.com/watch?v=K3JKmWmbbGM
@@ -105,7 +105,7 @@ function sisters_replace_meta_file
105
105
# Set-Content info: https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.management/Set-Content?f=255&MSPPError=-2147217396
106
106
107
107
# 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:
109
109
110
110
echo " ******** cat $FILE_CONTEXT : AFTER changes :"
111
111
cat $FILE_CONTEXT
@@ -137,7 +137,7 @@ $NOW = Get-Date -Format "yyyy-MM-ddTHH:mmzzz"
137
137
echo " ******** PSSCRIPTROOT= $PSSCRIPTROOT "
138
138
git -- version
139
139
140
- # exit #1
140
+ # exit #1
141
141
142
142
$REPONAME = ' sisters'
143
143
$UPSTREAM = " https://github.com/hotwilson/sisters" # a repo prepared for the class.
@@ -147,9 +147,9 @@ $NOW = Get-Date -Format "yyyy-MM-ddTHH:mmzzz"
147
147
$FileExists = Test-Path $REPONAME
148
148
if ($FileExists -eq $True ){
149
149
# 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}
151
151
}
152
-
152
+ echo " ******** Exit #2. "
153
153
# exit #2
154
154
155
155
# New-item ${REPONAME} -ItemType "directory" >$null # instead of mkdir ${REPONAME}
@@ -161,14 +161,15 @@ if ($FileExists -eq $True ){
161
161
# Notice the string concatenation format:
162
162
git clone " $ ( $GITHUB_REPO ) .git" # $REPONAME # --depth=1
163
163
164
- echo " ******** git tag -l cloned # lightweight tag for private temp use :"
164
+ echo " ******** git tag -l cloned # lightweight tag for private temp use :"
165
165
git tag - l cloned
166
166
# Note no spaces and thus no quotes.
167
- echo " ******** git tag (list) :"
167
+ echo " ******** git tag (list) :"
168
168
git tag
169
- echo " ******** git log :"
169
+ echo " ******** git log :"
170
170
git l -3
171
171
172
+ echo " ******** Exit #3."
172
173
# exit #3
173
174
174
175
echo " ******** Ensure $REPONAME folder is specified in .gitignore file:"
@@ -184,6 +185,7 @@ git tag
184
185
echo " ******** ${REPONAME} added to bottom of .gitignore file."
185
186
}
186
187
188
+ echo " ******** Exit #4."
187
189
# exit #4
188
190
189
191
@@ -202,21 +204,23 @@ $CurrentDir = $(get-location).Path;
202
204
echo " ******** Run PowerShell file for Git configurations at the repo level:"
203
205
# PS TRICK: Get parent folder path using the $MyInvocation built-in PS variable:
204
206
# 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
206
208
$UtilPath = Join-Path - Path $ScriptPath - ChildPath ..\
207
- # Write-Host "Path:" $UtilPath
209
+ # Write-Host "Path:" $UtilPath
208
210
# NOTE: PowerShell accepts both forward and backward slashes:
209
211
& " $UtilPath /git-client-config.ps1"
210
- # Alternately, use & to run scripts in same scope:
212
+ # Alternately, use & to run scripts in same scope:
211
213
# & "../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:
213
215
# . "../git_client-config.ps1 global" #
214
216
# echo "******** Present Working Directory :"
215
217
# pwd
218
+
219
+ echo " ******** Exit #6."
216
220
# exit #6
217
221
218
222
Write-Host " ******** git remote add upstream $UPSTREAM :"
219
- git remote add upstream ${UPSTREAM}
223
+ git remote add upstream ${UPSTREAM}
220
224
Write-Host " ******** git remote -v :"
221
225
git remote - v
222
226
Write-Host " ******** git remote show origin :"
@@ -225,10 +229,12 @@ git remote add upstream ${UPSTREAM}
225
229
echo " ******** cat .git/HEAD to show internal current branch HEAD :"
226
230
# The contents of HEAD is stored in this file:
227
231
cat .git/ HEAD
228
-
232
+
229
233
echo " ******** git branch -avv at master:"
230
234
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."
232
238
# exit #7
233
239
234
240
echo " ******** git l = git log of commits in repo:"
@@ -240,7 +246,7 @@ git branch -avv # shows tracking branches
240
246
dir
241
247
}else { # Mac / Linux:
242
248
ls # -al
243
- }
249
+ }
244
250
# tree
245
251
echo " ******** git reflog (showing only what occurred locally):"
246
252
git reflog
@@ -250,27 +256,30 @@ git branch -avv # shows tracking branches
250
256
echo " ******** git status at initial clone:"
251
257
git status
252
258
259
+ echo " ******** Exit #8."
253
260
# exit #8
254
261
255
262
echo " ******** cat ${REPONAME} /bebe.md at HEAD:"
256
263
cat bebe.md
257
264
258
265
echo " ******** git blame bebe.md : "
259
266
git blame bebe.md
260
- # NOTE:
267
+ # NOTE:
261
268
echo " ******** git l = git log of commits in repo:"
262
269
# add -10 to list 10 lines using l for log alias:
263
270
git l -10
264
271
# Notice the title "BeBe" and blank lines in the file are from the initial commit.
265
272
# Two lines were changed in the latest commit.
266
273
274
+ echo " ******** Exit #9."
267
275
# exit #9
268
276
269
277
# echo "******** git show --oneline --abbrev-commit - press q to quit:"
270
278
# git show --oneline --abbrev-commit
271
279
272
280
git diff HEAD..HEAD^
273
281
282
+ echo " ******** Exit #10."
274
283
# exit #10
275
284
276
285
# echo "******** Begin trace :"
@@ -285,14 +294,15 @@ git checkout master
285
294
$CURRENT_BRANCH = " feature1"
286
295
}else {
287
296
$CURRENT_BRANCH = $args [0 ]
288
- }
297
+ }
289
298
echo " ******** git checkout new branch "" $CURRENT_BRANCH "" from master branch :"
290
- git checkout - b $CURRENT_BRANCH
299
+ git checkout - b $CURRENT_BRANCH
291
300
git branch - avv
292
- # PS TRICK: Double-quotes to display words in quotes:
301
+ # PS TRICK: Double-quotes to display words in quotes:
293
302
echo " ******** git reflog at "" $CURRENT_BRANCH "" :"
294
303
git reflog
295
304
305
+ echo " ******** Exit #11."
296
306
# exit #11
297
307
298
308
$CURRENT_YEAR = " 1979"
@@ -302,6 +312,7 @@ sisters_new_photo-info $CURRENT_YEAR "Hartford, Connecticut"
302
312
# sisters_new_meta_file BeBe false "White buttoned shirt"
303
313
# Notice the person name is upper/lower case:
304
314
315
+ echo " ******** Exit #12."
305
316
# exit #12
306
317
307
318
echo " ******** git checkout "" @{10 minutes ago}"" :"
@@ -313,12 +324,14 @@ sisters_new_meta_file Bebe false "White buttoned shirt"
313
324
# echo "******** git add -p (hunks interactive) :"
314
325
# git add -p # GUI (requires manual response)
315
326
327
+ echo " ******** Exit #13."
316
328
exit # 13
317
329
318
330
sisters_new_meta_file Heather true " Plaid shirt"
319
331
sisters_new_meta_file Laurie false " Cable-knit sweater"
320
332
sisters_new_meta_file Mimi false " French sailor shirt"
321
333
334
+ echo " ******** Exit #14."
322
335
# exit #14
323
336
324
337
echo " ******** git stash :"
@@ -333,6 +346,7 @@ git stash list
333
346
echo " ******** git status (after git stash) :"
334
347
git status
335
348
349
+ echo " ******** Exit #15."
336
350
# exit #15
337
351
338
352
# Do something else
@@ -341,7 +355,8 @@ git stash list
341
355
git stash pop
342
356
echo " ******** git status : before git add :"
343
357
git status
344
-
358
+
359
+ echo " ******** Exit #16."
345
360
# exit #16
346
361
347
362
echo " ******** git add . :"
@@ -367,6 +382,7 @@ git commit -m"Snapshot for $CURRENT_YEAR"
367
382
echo " ******** git l = git log of commits in repo:"
368
383
git l
369
384
385
+ echo " ******** Exit #17."
370
386
exit # 17 --- major checkpoint here.
371
387
372
388
# Export an entire branch, complete with history, to the specified file:
@@ -382,15 +398,17 @@ exit #17 --- major checkpoint here.
382
398
}else { # Mac / Linux:
383
399
git archive $CURRENT_BRANCH -- format= tar -- output= $REPONAME_$CURRENT_BRANCH_$REPONAME.tar
384
400
}
385
- }
401
+ }
386
402
# list files archived.
387
403
404
+ echo " ******** Exit #18."
388
405
exit # 18
389
406
390
407
391
408
# git push --dry-run
392
409
393
410
411
+ echo " ******** Exit #20."
394
412
exit # 19
395
413
# exit #20 reserved
396
414
@@ -410,6 +428,7 @@ git checkout $CURRENT_COMMIT
410
428
echo " ******** git log at $CURRENT_BRANCH :"
411
429
git commit
412
430
431
+ echo " ******** Exit #21."
413
432
exit # 21
414
433
415
434
$CURRENT_COMMIT = " a874ef4"
@@ -420,6 +439,7 @@ git reset --soft $CURRENT_COMMIT
420
439
echo " ******** git reflog at $CURRENT_BRANCH :"
421
440
git reflog
422
441
442
+ echo " ******** Exit #22."
423
443
exit # 22
424
444
425
445
echo " ******** Make changes to files and stage it at $CURRENT_COMMIT :"
@@ -430,6 +450,7 @@ git reset HEAD
430
450
echo " ******** git fsck after $CURRENT_COMMIT :"
431
451
git fsck
432
452
453
+ echo " ******** Exit #23."
433
454
exit # 23
434
455
435
456
$CURRENT_COMMIT = " 82e957c"
@@ -439,12 +460,9 @@ git reset --hard $CURRENT_COMMIT
439
460
git fsck
440
461
441
462
442
- exit # 23
443
-
444
- echo " ******** $NOW ends."
445
-
463
+ echo " ******** Exit #24. $NOW ends."
446
464
exit # 24
447
465
448
466
# #############################
449
467
450
- # END OF FILE
468
+ # END OF FILE
0 commit comments