Set initial commit timestamp to be constant.
[git-darcs-import.git] / tests / amend-record.pl
blobbfcd018d36f75286e4b76b904d7975bbdde72798
1 #!/usr/bin/env perl
3 # Testing amend-record.
5 use lib 'lib/perl';
6 use Test::More 'no_plan';
7 use strict;
8 use Test::Darcs;
9 use Shell::Command;
10 use File::Slurp;
13 init_tmp_repo();
15 # Plain amend-record
16 touch 'foo';
17 darcs "add foo";
18 like( darcs("record -a -m add_foo"), qr/finished recording/i, 'added patch');
19 append_file('foo',"\nanother line");
21 like( echo_to_darcs("amend-record -a foo","y"), qr/amending changes/i, 'amend-record -a');
22 is($?,0, " return code == 0");
25 my $changes = darcs "changes -v";
26 like( $changes, qr/another line/, 'change amended properly');
29 # amend-record of removed file
30 touch 'bar1' ;
31 touch 'bar2' ;
32 append_file('bar1',"a line\n");
33 append_file('bar1',"a line\n");
34 darcs("add bar1 bar2");
35 like( darcs("record -a -m add_bars"), qr/finished recording/i, 'added another patch');
36 rm_f('bar2');
38 like( echo_to_darcs("amend-record -a","y"), qr/finished amending/i, 'amend-record removed file');
39 is($?,0, " return code == 0");
41 # Special case: patch is empty after amend
42 cp "foo","foo.old";
43 append_file('foo',"\nanother line");
45 like( darcs("record -a -m add_line foo"), qr/finished recording/i, 'record');
46 mv "foo.old","foo";
47 like( echo_to_darcs("amend -a foo","y"), qr/amending changes/i, 'amend makes empty patch');
48 is($?,0, " return code == 0");
50 # Amend --author, -m, etc
51 append_file('foo',"\nanother line");
52 like( echo_to_darcs("amend -a -m new_name foo","y"), qr/amending changes/i, 'amend');
53 like( darcs("changes --last=1"), qr/new_name/, 'amend can change patch name' );
55 append_file('foo',"\nanother line");
57 like( echo_to_darcs("amend -a -m new_name -A new_author foo","y"), qr/amending changes/i, 'amend');
58 like( darcs("changes --last=1"), qr/new_author/, 'amend can change patch author' );