-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo1.ps1
89 lines (72 loc) · 1.83 KB
/
demo1.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
param($startDir)
if ($startDir -eq "" -or $startDir -eq $NULL) {
WriteComment('A working directory is required.')
exit
}
Import-Module -Name .\Demo-Module.psm1
$demoDir = $startDir + "\demo1"
$dev1 = $demoDir + "\AliceRepo"
$dev2 = $demoDir + "\BobRepo"
$remote = $demoDir + "\RemoteRepo"
cls
WriteComment('Clear out a folder for the demo, and create new folders.')
WriteComment('Create ' + $demoDir)
WriteComment('Create ' + $remote)
WriteComment('Create ' + $dev1)
WriteComment('Create ' + $dev2)
rm -fo -r $demoDir
mkdir $demoDir | out-null
pushd $demoDir
mkdir $dev1 | out-null
mkdir $dev2 | out-null
mkdir $remote | out-null
WriteComment('Create the remote repository')
cd $remote
EchoAndExecute 'git init'
echo ""
WriteComment('Alice and Bob both clone the remote repo.')
cd $dev1
EchoAndExecute "git clone $remote"
echo ""
cd $dev2
EchoAndExecute "git clone $remote"
echo ""
WaitForKeypress
cls
#------------------------------------------------------------
WriteComment('Alice makes some changes and checks in.')
cd $dev1
$x = @"
bread
lettuce
tomato
bread
"@
WriteFile $x ($dev1 + '\Sandwich.txt')
EchoAndExecute 'git status'
EchoAndExecute 'git add .'
EchoAndExecute 'git status'
EchoAndExecute 'git commit -m "Added a sandwich." --author=''Alice <[email protected]>'''
WaitForKeypress
cls
#------------------------------------------------------------
cd $dev1
$x = @"
bread
bacon
lettuce
tomato
bread
"@
WriteFile $x 'Sandwich.txt'
EchoAndExecute 'git add .'
EchoAndExecute 'git status'
EchoAndExecute 'git commit -m "Made sandwich into a BLT." --author=''Bob <[email protected]>'''
EchoAndExecute 'git mv Sandwich.txt BLT.txt'
EchoAndExecute 'git status'
EchoAndExecute 'git commit -m "Renamed sandwich to BLT." --author=''Bob <[email protected]>'''
WaitForKeypress
cls
#------------------------------------------------------------
popd
popd