@@ -153,6 +153,127 @@ new
153
153
) ;
154
154
}
155
155
156
+ #[ test]
157
+ fn simple_straightline_tag_and_reference ( ) {
158
+ let td = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
159
+ git_init ( & td) ;
160
+
161
+ let base = "v0.1.0" ;
162
+
163
+ git_commits ( & [ "a" , "b" ] , & td) ;
164
+ git ( & [ "tag" , base] , & td) ;
165
+ git ( & [ "checkout" , "-b" , "changes" ] , & td) ;
166
+ git_commits ( & [ "target" , "d" ] , & td) ;
167
+
168
+ let log = git_log ( & td) ;
169
+ assert_eq ! (
170
+ log,
171
+ "\
172
+ * d HEAD -> changes
173
+ * target
174
+ * b tag: v0.1.0, main
175
+ * a
176
+ " ,
177
+ "log:\n {}" ,
178
+ log
179
+ ) ;
180
+
181
+ td. child ( "new" ) . touch ( ) . unwrap ( ) ;
182
+ git ( & [ "add" , "new" ] , & td) ;
183
+
184
+ fixup ( & td)
185
+ . args ( [ "-P" , "target" , "-u" , base] )
186
+ . assert ( )
187
+ . success ( ) ;
188
+
189
+ let ( files, err) = git_changed_files ( "target" , & td) ;
190
+
191
+ assert_eq ! (
192
+ files,
193
+ "\
194
+ file_target
195
+ new
196
+ " ,
197
+ "out: {} err: {}" ,
198
+ files,
199
+ err
200
+ ) ;
201
+
202
+ // also check that we can use the full refspec definition
203
+
204
+ td. child ( "new-full-ref" ) . touch ( ) . unwrap ( ) ;
205
+ git ( & [ "add" , "new-full-ref" ] , & td) ;
206
+ fixup ( & td)
207
+ . args ( [ "-P" , "target" , "-u" , & format ! ( "refs/tags/{base}" ) ] )
208
+ . unwrap ( ) ;
209
+
210
+ let ( files, err) = git_changed_files ( "target" , & td) ;
211
+ assert_eq ! (
212
+ files,
213
+ "\
214
+ file_target
215
+ new
216
+ new-full-ref
217
+ " ,
218
+ "out: {} err: {}" ,
219
+ files,
220
+ err
221
+ ) ;
222
+ }
223
+
224
+ #[ test]
225
+ fn simple_straightline_remote_branch ( ) {
226
+ let remote_td = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
227
+ git_init ( & remote_td) ;
228
+ git_commits ( & [ "a" , "b" ] , & remote_td) ;
229
+
230
+ let td = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
231
+ git_init ( & td) ;
232
+ let remote_path = & remote_td
233
+ . path ( )
234
+ . as_os_str ( )
235
+ . to_owned ( )
236
+ . into_string ( )
237
+ . unwrap ( ) ;
238
+ git ( & [ "remote" , "add" , "origin" , remote_path] , & td) ;
239
+ git ( & [ "pull" , "origin" , "main:main" ] , & td) ;
240
+ git_commits ( & [ "target" , "d" ] , & td) ;
241
+
242
+ let log = git_log ( & td) ;
243
+ assert_eq ! (
244
+ log,
245
+ "\
246
+ * d HEAD -> main
247
+ * target
248
+ * b origin/main
249
+ * a
250
+ " ,
251
+ "log:\n {}" ,
252
+ log
253
+ ) ;
254
+
255
+ td. child ( "new" ) . touch ( ) . unwrap ( ) ;
256
+ git ( & [ "add" , "new" ] , & td) ;
257
+
258
+ fixup ( & td)
259
+ . args ( [ "-P" , "target" , "-u" , "origin/main" ] )
260
+ . assert ( )
261
+ . success ( ) ;
262
+
263
+ let ( files, err) = git_changed_files ( "target" , & td) ;
264
+
265
+ assert_eq ! (
266
+ files,
267
+ "\
268
+ file_target
269
+ new
270
+ " ,
271
+ "out: {} err: {}" ,
272
+ files,
273
+ err
274
+ ) ;
275
+ }
276
+
156
277
#[ test]
157
278
fn stashes_before_rebase ( ) {
158
279
let td = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
@@ -389,7 +510,7 @@ fn git_init_default_branch_name(name: &str, tempdir: &assert_fs::TempDir) {
389
510
fn git_file_commit ( name : & str , tempdir : & assert_fs:: TempDir ) {
390
511
tempdir. child ( format ! ( "file_{}" , name) ) . touch ( ) . unwrap ( ) ;
391
512
git ( & [ "add" , "-A" ] , tempdir) ;
392
- git ( & [ "commit" , "-m" , & name] , tempdir) ;
513
+ git ( & [ "commit" , "-m" , name] , tempdir) ;
393
514
}
394
515
395
516
/// Get the git shown output for the target commit
0 commit comments