@@ -18,7 +18,7 @@ public class BranchFixture : BaseFixture
18
18
public void CanCreateBranch ( string name )
19
19
{
20
20
string path = SandboxBareTestRepo ( ) ;
21
- using ( var repo = new Repository ( path ) )
21
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
22
22
{
23
23
EnableRefLog ( repo ) ;
24
24
@@ -39,8 +39,10 @@ public void CanCreateBranch(string name)
39
39
Assert . NotNull ( repo . Branches . SingleOrDefault ( p => p . Name . Normalize ( ) == name ) ) ;
40
40
41
41
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
42
+ "branch: Created from " + committish ,
43
+ null ,
42
44
newBranch . Tip . Id ,
43
- "branch: Created from " + committish ) ;
45
+ Constants . Identity , DateTimeOffset . Now ) ;
44
46
45
47
repo . Branches . Remove ( newBranch . Name ) ;
46
48
Assert . Null ( repo . Branches [ name ] ) ;
@@ -86,7 +88,7 @@ public void CanCreateAnUnbornBranch()
86
88
public void CanCreateBranchUsingAbbreviatedSha ( )
87
89
{
88
90
string path = SandboxBareTestRepo ( ) ;
89
- using ( var repo = new Repository ( path ) )
91
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
90
92
{
91
93
EnableRefLog ( repo ) ;
92
94
@@ -98,8 +100,10 @@ public void CanCreateBranchUsingAbbreviatedSha()
98
100
Assert . Equal ( "be3563ae3f795b2b4353bcce3a527ad0a4f7f644" , newBranch . Tip . Sha ) ;
99
101
100
102
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
103
+ "branch: Created from " + committish ,
104
+ null ,
101
105
newBranch . Tip . Id ,
102
- "branch: Created from " + committish ) ;
106
+ Constants . Identity , DateTimeOffset . Now ) ;
103
107
}
104
108
}
105
109
@@ -109,7 +113,7 @@ public void CanCreateBranchUsingAbbreviatedSha()
109
113
public void CanCreateBranchFromImplicitHead ( string headCommitOrBranchSpec )
110
114
{
111
115
string path = SandboxStandardTestRepo ( ) ;
112
- using ( var repo = new Repository ( path ) )
116
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
113
117
{
114
118
EnableRefLog ( repo ) ;
115
119
@@ -126,8 +130,10 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
126
130
Assert . NotNull ( repo . Branches . SingleOrDefault ( p => p . Name == name ) ) ;
127
131
128
132
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
133
+ "branch: Created from " + headCommitOrBranchSpec ,
134
+ null ,
129
135
newBranch . Tip . Id ,
130
- "branch: Created from " + headCommitOrBranchSpec ) ;
136
+ Constants . Identity , DateTimeOffset . Now ) ;
131
137
}
132
138
}
133
139
@@ -137,7 +143,7 @@ public void CanCreateBranchFromImplicitHead(string headCommitOrBranchSpec)
137
143
public void CanCreateBranchFromExplicitHead ( string headCommitOrBranchSpec )
138
144
{
139
145
string path = SandboxStandardTestRepo ( ) ;
140
- using ( var repo = new Repository ( path ) )
146
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
141
147
{
142
148
EnableRefLog ( repo ) ;
143
149
@@ -149,16 +155,18 @@ public void CanCreateBranchFromExplicitHead(string headCommitOrBranchSpec)
149
155
Assert . Equal ( "32eab9cb1f450b5fe7ab663462b77d7f4b703344" , newBranch . Tip . Sha ) ;
150
156
151
157
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
158
+ "branch: Created from HEAD" ,
159
+ null ,
152
160
newBranch . Tip . Id ,
153
- "branch: Created from " + headCommitOrBranchSpec ) ;
161
+ Constants . Identity , DateTimeOffset . Now ) ;
154
162
}
155
163
}
156
164
157
165
[ Fact ]
158
166
public void CanCreateBranchFromCommit ( )
159
167
{
160
168
string path = SandboxBareTestRepo ( ) ;
161
- using ( var repo = new Repository ( path ) )
169
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
162
170
{
163
171
EnableRefLog ( repo ) ;
164
172
@@ -169,16 +177,18 @@ public void CanCreateBranchFromCommit()
169
177
Assert . Equal ( "4c062a6361ae6959e06292c1fa5e2822d9c96345" , newBranch . Tip . Sha ) ;
170
178
171
179
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
180
+ "branch: Created from " + newBranch . Tip . Sha ,
181
+ null ,
172
182
newBranch . Tip . Id ,
173
- "branch: Created from " + newBranch . Tip . Sha ) ;
183
+ Constants . Identity , DateTimeOffset . Now ) ;
174
184
}
175
185
}
176
186
177
187
[ Fact ]
178
188
public void CanCreateBranchFromRevparseSpec ( )
179
189
{
180
190
string path = SandboxBareTestRepo ( ) ;
181
- using ( var repo = new Repository ( path ) )
191
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
182
192
{
183
193
EnableRefLog ( repo ) ;
184
194
@@ -190,8 +200,10 @@ public void CanCreateBranchFromRevparseSpec()
190
200
Assert . Equal ( "9fd738e8f7967c078dceed8190330fc8648ee56a" , newBranch . Tip . Sha ) ;
191
201
192
202
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
203
+ "branch: Created from " + committish ,
204
+ null ,
193
205
newBranch . Tip . Id ,
194
- "branch: Created from " + committish ) ;
206
+ Constants . Identity , DateTimeOffset . Now ) ;
195
207
}
196
208
}
197
209
@@ -201,7 +213,7 @@ public void CanCreateBranchFromRevparseSpec()
201
213
public void CreatingABranchFromATagPeelsToTheCommit ( string committish )
202
214
{
203
215
string path = SandboxBareTestRepo ( ) ;
204
- using ( var repo = new Repository ( path ) )
216
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
205
217
{
206
218
EnableRefLog ( repo ) ;
207
219
@@ -212,8 +224,10 @@ public void CreatingABranchFromATagPeelsToTheCommit(string committish)
212
224
Assert . Equal ( "e90810b8df3e80c413d903f631643c716887138d" , newBranch . Tip . Sha ) ;
213
225
214
226
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
227
+ "branch: Created from " + committish ,
228
+ null ,
215
229
newBranch . Tip . Id ,
216
- "branch: Created from " + committish ) ;
230
+ Constants . Identity , DateTimeOffset . Now ) ;
217
231
}
218
232
}
219
233
@@ -559,7 +573,7 @@ public void CanGetTrackingInformationFromBranchSharingNoHistoryWithItsTrackedBra
559
573
{
560
574
Branch master = repo . Branches [ "master" ] ;
561
575
const string logMessage = "update target message" ;
562
- repo . Refs . UpdateTarget ( "refs/remotes/origin/master" , "origin/test" , Constants . Signature , logMessage ) ;
576
+ repo . Refs . UpdateTarget ( "refs/remotes/origin/master" , "origin/test" , logMessage ) ;
563
577
564
578
Assert . True ( master . IsTracking ) ;
565
579
Assert . NotNull ( master . TrackedBranch ) ;
@@ -964,7 +978,7 @@ public void TwoBranchesPointingAtTheSameCommitAreNotBothCurrent()
964
978
public void CanRenameABranch ( )
965
979
{
966
980
string path = SandboxBareTestRepo ( ) ;
967
- using ( var repo = new Repository ( path ) )
981
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
968
982
{
969
983
EnableRefLog ( repo ) ;
970
984
@@ -980,8 +994,10 @@ public void CanRenameABranch()
980
994
Assert . NotNull ( repo . Branches [ "br3" ] ) ;
981
995
982
996
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
997
+ string . Format ( "branch: renamed {0} to {1}" , br2 . CanonicalName , newBranch . CanonicalName ) ,
998
+ br2 . Tip . Id ,
983
999
newBranch . Tip . Id ,
984
- string . Format ( "branch: renamed {0} to {1}" , br2 . CanonicalName , newBranch . CanonicalName ) ) ;
1000
+ Constants . Identity , DateTimeOffset . Now ) ;
985
1001
}
986
1002
}
987
1003
@@ -999,7 +1015,7 @@ public void BlindlyRenamingABranchOverAnExistingOneThrows()
999
1015
public void CanRenameABranchWhileOverwritingAnExistingOne ( )
1000
1016
{
1001
1017
string path = SandboxBareTestRepo ( ) ;
1002
- using ( var repo = new Repository ( path ) )
1018
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
1003
1019
{
1004
1020
EnableRefLog ( repo ) ;
1005
1021
@@ -1021,9 +1037,10 @@ public void CanRenameABranchWhileOverwritingAnExistingOne()
1021
1037
Assert . Equal ( br2 . Tip , newTest . Tip ) ;
1022
1038
1023
1039
AssertRefLogEntry ( repo , newBranch . CanonicalName ,
1024
- newBranch . Tip . Id ,
1025
1040
string . Format ( "branch: renamed {0} to {1}" , br2 . CanonicalName , newBranch . CanonicalName ) ,
1026
- test . Tip . Id ) ;
1041
+ br2 . Tip . Id ,
1042
+ newTest . Tip . Id ,
1043
+ Constants . Identity , DateTimeOffset . Now ) ;
1027
1044
}
1028
1045
}
1029
1046
@@ -1129,32 +1146,42 @@ private static T[] SortedBranches<T>(IEnumerable<Branch> branches, Func<Branch,
1129
1146
public void CreatingABranchIncludesTheCorrectReflogEntries ( )
1130
1147
{
1131
1148
string path = SandboxStandardTestRepo ( ) ;
1132
- using ( var repo = new Repository ( path ) )
1149
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
1133
1150
{
1134
1151
EnableRefLog ( repo ) ;
1135
1152
var branch = repo . Branches . Add ( "foo" , repo . Head . Tip ) ;
1136
- AssertRefLogEntry ( repo , branch . CanonicalName , branch . Tip . Id ,
1137
- string . Format ( "branch: Created from {0}" , repo . Head . Tip . Sha ) ) ;
1138
1153
1139
- branch = repo . Branches . Add ( "bar" , repo . Head . Tip , null , "BAR" ) ;
1140
- AssertRefLogEntry ( repo , branch . CanonicalName , repo . Head . Tip . Id , "BAR" ) ;
1154
+ AssertRefLogEntry ( repo , branch . CanonicalName ,
1155
+ string . Format ( "branch: Created from {0}" , repo . Head . Tip . Sha ) ,
1156
+ null , branch . Tip . Id ,
1157
+ Constants . Identity , DateTimeOffset . Now ) ;
1158
+
1159
+ branch = repo . Branches . Add ( "bar" , repo . Head . Tip ) ;
1160
+
1161
+ AssertRefLogEntry ( repo , branch . CanonicalName ,
1162
+ "branch: Created from " + repo . Head . Tip . Sha ,
1163
+ null , repo . Head . Tip . Id ,
1164
+ Constants . Identity , DateTimeOffset . Now ) ;
1141
1165
}
1142
1166
}
1143
1167
1144
1168
[ Fact ]
1145
1169
public void RenamingABranchIncludesTheCorrectReflogEntries ( )
1146
1170
{
1147
1171
string path = SandboxStandardTestRepo ( ) ;
1148
- using ( var repo = new Repository ( path ) )
1172
+ using ( var repo = new Repository ( path , new RepositoryOptions { Identity = Constants . Identity } ) )
1149
1173
{
1150
1174
EnableRefLog ( repo ) ;
1151
1175
var master = repo . Branches [ "master" ] ;
1152
1176
var newMaster = repo . Branches . Rename ( master , "new-master" ) ;
1153
- AssertRefLogEntry ( repo , newMaster . CanonicalName , newMaster . Tip . Id ,
1154
- "branch: renamed refs/heads/master to refs/heads/new-master" ) ;
1155
-
1156
- newMaster = repo . Branches . Rename ( newMaster , "new-master2" , null , "MOVE" ) ;
1157
- AssertRefLogEntry ( repo , newMaster . CanonicalName , newMaster . Tip . Id , "MOVE" ) ;
1177
+ AssertRefLogEntry ( repo , newMaster . CanonicalName , "branch: renamed refs/heads/master to refs/heads/new-master" ,
1178
+ newMaster . Tip . Id , newMaster . Tip . Id ,
1179
+ Constants . Identity , DateTimeOffset . Now ) ;
1180
+
1181
+ var newMaster2 = repo . Branches . Rename ( newMaster , "new-master2" ) ;
1182
+ AssertRefLogEntry ( repo , newMaster2 . CanonicalName , "branch: renamed refs/heads/new-master to refs/heads/new-master2" ,
1183
+ newMaster . Tip . Id , newMaster2 . Tip . Id ,
1184
+ Constants . Identity , DateTimeOffset . Now ) ;
1158
1185
}
1159
1186
}
1160
1187
}
0 commit comments