@@ -23,7 +23,7 @@ public void NormalisationOfPullRequestsWithFetch()
23
23
localFixture . Checkout ( commit . Sha ) ;
24
24
GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : string . Empty ) ;
25
25
26
- var normalisedPullBranch = localFixture . Repository . FindBranch ( "pull/3/merge" ) ;
26
+ var normalisedPullBranch = localFixture . Repository . Branches [ "pull/3/merge" ] ;
27
27
normalisedPullBranch . ShouldNotBe ( null ) ;
28
28
}
29
29
}
@@ -51,24 +51,30 @@ public void NormalisationOfPullRequestsWithoutFetch()
51
51
}
52
52
53
53
[ Test ]
54
- public void UpdatesLocalBranchesWhen ( )
54
+ public void NormalisationOfTag ( )
55
55
{
56
56
using ( var fixture = new EmptyRepositoryFixture ( ) )
57
57
{
58
58
fixture . Repository . MakeACommit ( ) ;
59
59
60
60
fixture . Repository . Checkout ( fixture . Repository . CreateBranch ( "feature/foo" ) ) ;
61
61
fixture . Repository . MakeACommit ( ) ;
62
+
63
+ fixture . BranchTo ( "release/2.0.0" ) ;
64
+ fixture . MakeACommit ( ) ;
65
+ fixture . MakeATaggedCommit ( "2.0.0-rc.1" ) ;
66
+ fixture . Checkout ( "master" ) ;
67
+ fixture . MergeNoFF ( "release/2.0.0" ) ;
68
+ fixture . Repository . Branches . Remove ( fixture . Repository . Branches [ "release/2.0.0" ] ) ;
69
+ var remoteTagSha = fixture . Repository . Tags [ "2.0.0-rc.1" ] . Target . Sha ;
70
+
62
71
using ( var localFixture = fixture . CloneRepository ( ) )
63
72
{
64
- localFixture . Checkout ( "feature/foo" ) ;
65
- // Advance remote
66
- var advancedCommit = fixture . Repository . MakeACommit ( ) ;
67
- GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : null ) ;
73
+ localFixture . Checkout ( remoteTagSha ) ;
74
+ GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : string . Empty ) ;
68
75
69
- var normalisedBranch = localFixture . Repository . FindBranch ( "feature/foo" ) ;
70
- normalisedBranch . ShouldNotBe ( null ) ;
71
- normalisedBranch . Tip . Sha . ShouldBe ( advancedCommit . Sha ) ;
76
+ localFixture . Repository . Head . FriendlyName . ShouldBe ( "(no branch)" ) ;
77
+ localFixture . Repository . Head . Tip . Sha . ShouldBe ( remoteTagSha ) ;
72
78
}
73
79
}
74
80
}
@@ -89,13 +95,10 @@ public void UpdatesCurrentBranch()
89
95
var advancedCommit = fixture . Repository . MakeACommit ( ) ;
90
96
Commands . Fetch ( ( Repository ) localFixture . Repository , localFixture . Repository . Network . Remotes [ "origin" ] . Name , new string [ 0 ] , null , null ) ;
91
97
localFixture . Repository . Checkout ( advancedCommit . Sha ) ;
92
- localFixture . Repository . DumpGraph ( ) ;
93
- GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : "ref/heads/develop" ) ;
98
+ GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : "refs/heads/develop" ) ;
94
99
95
- var normalisedBranch = localFixture . Repository . FindBranch ( "develop" ) ;
100
+ var normalisedBranch = localFixture . Repository . Branches [ "develop" ] ;
96
101
normalisedBranch . ShouldNotBe ( null ) ;
97
- fixture . Repository . DumpGraph ( ) ;
98
- localFixture . Repository . DumpGraph ( ) ;
99
102
normalisedBranch . Tip . Sha . ShouldBe ( advancedCommit . Sha ) ;
100
103
localFixture . Repository . Head . Tip . Sha . ShouldBe ( advancedCommit . Sha ) ;
101
104
}
@@ -125,10 +128,53 @@ public void ShouldNotChangeBranchWhenNormalizingTheDirectory()
125
128
126
129
GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : null ) ;
127
130
128
- localFixture . Repository . DumpGraph ( ) ;
129
131
localFixture . Repository . Head . Tip . Sha . ShouldBe ( lastCommitOnDevelop . Sha ) ;
130
132
}
131
133
}
132
134
}
135
+
136
+ [ Test ]
137
+ public void ShouldNotMoveLocalBranchWhenRemoteAdvances ( )
138
+ {
139
+ using ( var fixture = new EmptyRepositoryFixture ( ) )
140
+ {
141
+ fixture . Repository . MakeACommit ( ) ;
142
+
143
+ fixture . Repository . Checkout ( fixture . Repository . CreateBranch ( "feature/foo" ) ) ;
144
+ fixture . Repository . MakeACommit ( ) ;
145
+ using ( var localFixture = fixture . CloneRepository ( ) )
146
+ {
147
+ localFixture . Checkout ( "feature/foo" ) ;
148
+ var expectedTip = localFixture . Repository . Head . Tip ;
149
+ // Advance remote
150
+ fixture . Repository . MakeACommit ( ) ;
151
+ GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : null ) ;
152
+
153
+ var normalisedBranch = localFixture . Repository . Branches [ "feature/foo" ] ;
154
+ normalisedBranch . ShouldNotBe ( null ) ;
155
+ normalisedBranch . Tip . Sha . ShouldBe ( expectedTip . Sha ) ;
156
+ }
157
+ }
158
+ }
159
+
160
+ [ Test ]
161
+ public void CheckedOutShaShouldNotChanged ( )
162
+ {
163
+ using ( var fixture = new EmptyRepositoryFixture ( ) )
164
+ {
165
+ fixture . Repository . MakeACommit ( ) ;
166
+ var commitToBuild = fixture . Repository . MakeACommit ( ) ;
167
+ fixture . Repository . MakeACommit ( ) ;
168
+
169
+ using ( var localFixture = fixture . CloneRepository ( ) )
170
+ {
171
+ localFixture . Repository . Checkout ( commitToBuild ) ;
172
+ GitRepositoryHelper . NormalizeGitDirectory ( localFixture . RepositoryPath , new AuthenticationInfo ( ) , noFetch : false , currentBranch : "refs/heads/master" ) ;
173
+
174
+ var normalisedBranch = localFixture . Repository . Branches [ "master" ] ;
175
+ normalisedBranch . Tip . Sha . ShouldBe ( commitToBuild . Sha ) ;
176
+ }
177
+ }
178
+ }
133
179
}
134
180
}
0 commit comments