Last active
August 5, 2020 04:27
-
-
Save jca02266/4bd02b6bd47562ab04a68a7389ef9b4f to your computer and use it in GitHub Desktop.
git-svn: keep timestamp of git commit date when do "git svn dcommit"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- git-svn.perl.orig 2017-07-09 03:29:19.208317700 +0900 | |
+++ git-svn.perl 2017-07-11 23:17:29.997533800 +0900 | |
@@ -16,6 +16,7 @@ | |
use File::Spec; | |
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/; | |
use Memoize; | |
+use POSIX qw/strftime/; | |
use Git::SVN; | |
use Git::SVN::Editor; | |
@@ -52,6 +53,8 @@ | |
Memoize::memoize 'Git::config_bool'; | |
} | |
+# avoid to output "Wide character in print at" | |
+binmode(STDOUT, ":utf8"); | |
# From which subdir have we been invoked? | |
my $cmd_dir_prefix = eval { | |
@@ -995,9 +998,12 @@ | |
$rewritten_parent); | |
} | |
+ my $ra = Git::SVN::Ra->new($url); | |
+ my $log_entry = get_commit_entry($d); | |
+ | |
my %ed_opts = ( r => $last_rev, | |
- log => get_commit_entry($d)->{log}, | |
- ra => Git::SVN::Ra->new($url), | |
+ log => $log_entry->{log}, | |
+ ra => $ra, | |
config => SVN::Core::config_get_config( | |
$Git::SVN::Ra::config_dir | |
), | |
@@ -1023,9 +1029,13 @@ | |
$gs->{inject_parents_dcommit}->{$cmt_rev} = | |
$parents->{$d}; | |
} | |
+ | |
+ my $author_date = strftime("%Y-%m-%dT%H:%M:%S.000000Z", gmtime($log_entry->{date})); | |
+ $ra->change_rev_prop($cmt_rev, 'svn:date', $author_date); | |
$_fetch_all ? $gs->fetch_all : $gs->fetch; | |
$SVN::Error::handler = $err_handler; | |
$last_rev = $cmt_rev; | |
+ | |
next if $_no_rebase; | |
my @diff = dcommit_rebase(@$linear_refs == 0, $d, | |
@@ -1852,7 +1862,11 @@ | |
while (<$msg_fh>) { | |
if (!$in_msg) { | |
$in_msg = 1 if (/^$/); | |
- $author = $1 if (/^author (.*>)/); | |
+ if (/^author (.*>) (\d+) ([\-\+]?\d+)$/o) { | |
+ $author = $1; | |
+ my($t, $tz) = ($2, $3); | |
+ $log_entry{date} = Git::SVN::Log::parse_git_date($t, $tz); | |
+ } | |
} elsif (/^git-svn-id: /) { | |
# skip this for now, we regenerate the | |
# correct one on re-fetch anyways |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use this script. Any instructions on usage would be helpful.