我想在舊版本的Subversion版本庫上使用git。我們有多個用戶在使用新的git remote(origin/master),這是舊版repo的git svn克隆。問題是,當我們執行git svn dcommit將新git repo的更改推送到舊的subversion repo時,提交者的用戶名會丟失,而是被git svn clone'd用戶的信息所取代。有沒有辦法在dcommit上保存提交者的信息到顛覆者中?git svn dcommit與svn用戶名
回答
要求每個人都使用「簽署的off-by」或其中的每一個承諾的消息在他們的用戶名的其他方式。這是一個相當醜陋的解決方案,但AFAIK是唯一可以在不破解git-svn源代碼的情況下完成的。
如果我正確理解該要求,則不是這樣。查看我的答案以獲得實際解決方案。 – 2011-05-02 19:43:55
Github的救援和往常一樣!他們的git svn快速概覽進入用戶映射:http://help.github.com/svn-importing/
基本上,你創建一個包含你想要的映射的文件。
我不確定這會起作用。作者映射用於將SVN導入Git,而不是將您的Git提交回SVN。 – awendt 2011-05-04 12:56:11
我相信它有效。當然,我已經使用git-svn來處理SVN倉庫,而不僅僅是一個導入工具。 – 2011-05-17 14:12:04
這並沒有解釋如何做任何事情,鏈接不再包含用戶映射信息,即使它做到了,我不認爲它適用於當您推送到svn – 2013-05-23 19:28:40
您可以使用git - svn的與--add-author-from
和--use-log-author
。前者表示提交消息中的From:
行中的git作者,後者進行反向轉換。
這就是說,repository formats matter和顛覆庫格式比git的一個窮。它不支持合併,或提交者與作者或提交時間不同於推送時間。 git-svn可以在本地獲得git ui,但對於數據模型卻無能爲力。希望你能夠遷移到一個git倉庫,可能有一個svn前端(現在有git-svnserver和github的閉源選項)。
我知道這是一個很老的話題,但如果有人有興趣,我添加這個技巧到我的本地混帳SVN的副本:
23a24
> use POSIX qw/strftime/;
984a986
> my $ra = Git::SVN::Ra->new($url);
987c989
< ra => Git::SVN::Ra->new($url),
---
> ra => $ra,
995a998,1014
> my $cmt_author = get_commit_entry($d)->{author};
> my $cmt_date = get_commit_entry($d)->{date};
> if (defined $cmt_author) {
> foreach my $key (keys %users) {
> my $i = index($cmt_author, $users{$key}[1]);
> if ($i != -1) {
> print "Changed author to $key\n";
> $ra->change_rev_prop($cmt_rev, 'svn:author', $key);
> last;
> }
> }
> }
> if (defined $cmt_date) {
> $cmt_date = strftime("%Y-%m-%dT%H:%M:%S.000000Z", gmtime($cmt_date));
> print "Changed date to $cmt_date\n";
> $ra->change_rev_prop($cmt_rev, 'svn:date', $cmt_date);
> }
1758c1777
< my %log_entry = (log => '', tree => get_tree_from_treeish($treeish));
---
> my %log_entry = (log => '', tree => get_tree_from_treeish($treeish), author => undef, date => undef);
1768a1788
> my $date;
1774c1794,1797
< $author = $1 if (/^author (.*>)/);
---
> if (/^author (.*>) (\d+) ([\-\+]?\d+)$/o) {
> $author = $1;
> $date = Git::SVN::Log::parse_git_date($2, $3);
> }
1792a1816,1817
> $log_entry{author} = $author || undef;
> $log_entry{date} = $date || undef;
這是對1.9.1-1(deb包版本在Ubuntu 14.04上)。這是不可配置的,因爲如果你有一個users.txt文件,它會使用它,它會一直嘗試和設置日期。此外,如果你有一個給定的git用戶有多個SVN帳戶,它只會選擇一個。
而我纔剛剛開始在憤怒中使用它,但我認爲它可能做的工作,祈禱!
問候 亞當
我修改了一下提出的修補程序通過Adam Sutton,使git svn dcommit
接受--commit-author
選項:
--- ./git-svn.orig 2014-10-09 23:11:40.032767542 +0300
+++ ./git-svn 2014-10-09 23:27:58.252753020 +0300
@@ -116,7 +116,7 @@
$_before, $_after,
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_parents, $_local,
$_prefix, $_no_checkout, $_url, $_verbose,
- $_commit_url, $_tag, $_merge_info, $_interactive);
+ $_commit_url, $_commit_author, $_tag, $_merge_info, $_interactive);
# This is a refactoring artifact so Git::SVN can get at this git-svn switch.
sub opt_prefix { return $_prefix || '' }
@@ -194,6 +194,7 @@
'dry-run|n' => \$_dry_run,
'fetch-all|all' => \$_fetch_all,
'commit-url=s' => \$_commit_url,
+ 'commit-author=s' => \$_commit_author,
'revision|r=i' => \$_revision,
'no-rebase' => \$_no_rebase,
'mergeinfo=s' => \$_merge_info,
@@ -982,6 +983,7 @@
$rewritten_parent);
}
+ my $ra = Git::SVN::Ra->new($url);
my %ed_opts = (r => $last_rev,
log => get_commit_entry($d)->{log},
ra => $ra,
@@ -993,6 +995,10 @@
editor_cb => sub {
print "Committed r$_[0]\n";
$cmt_rev = $_[0];
+ if (defined($_commit_author)) {
+ print "Changed author to $_commit_author\n";
+ $ra->change_rev_prop($cmt_rev, 'svn:author', $_commit_author);
+ }
},
mergeinfo => $_merge_info,
svn_path => '');
@@ -1790,6 +1796,7 @@
}
print $log_fh $msgbuf or croak $!;
command_close_pipe($msg_fh, $ctx);
+ $log_entry{author} = $author || undef;
}
close $log_fh or croak $!;
這是從亞當薩頓的回答 另一略加修改它創建一個反向映射從作者文件,並做一些額外的檢查重複和/或缺少作者。 它還告訴你在哪個Git用戶被映射到哪個SVN用戶的每個提交,即使在運行git svn dcommit --dry-run時。
[[email protected] git-svn-bridge]# diff scripts/git-svn.orig scripts/git-svn.hacked
23a24
> use POSIX;
963a965,975
>
> #Revert the keys/values from authors into a reverse map.
> #If a duplicate is found(i.e. 2 git users matching 1 svn user) abort the operation.
> my %rev_author_map;
> while (my ($key, @value) = each %users) {
> my $rev_key="$value[0][0] <$value[0][1]>";
> if(exists $rev_author_map{$rev_key}) {
> fatal "Found a duplicate GIT author($rev_key) in the authorsfile. Aborting dcommit!"
> }
> $rev_author_map{$rev_key}=$key
> }
972a985,997
> my $commit_entry = get_commit_entry($d);
> my $cmt_author = $commit_entry->{author};
> my $cmt_date = $commit_entry->{date};
> print "GIT AUTHOR: $cmt_author; \n";
> if(defined $cmt_author) {
> my $svn_author = $rev_author_map{$cmt_author};
> #Here we check if the git commit author matches an author in the authorsfile
> if ((not (defined $svn_author)) || $svn_author eq "") {
> fatal "The git author: $cmt_author was not found in the authors file. Make sure you have commited as a user listed in the authors file. Note:matching is case sensitive.";
> }
> print "SVN AUTHOR: $svn_author\n";
> }
>
984c1009
<
---
> my $ra = Git::SVN::Ra->new($url);
987c1012
< ra => Git::SVN::Ra->new($url),
---
> ra => $ra,
995a1021,1032
> #Here we coerce SVN into accepting the correct user according to the reverse mapping.
> if(defined $cmt_author) {
> my $svn_author = $rev_author_map{$cmt_author};
> print "SVN AUTHOR: $svn_author\n";
> $ra->change_rev_prop($cmt_rev, 'svn:author', $svn_author)
> }
> #Here we coerce SVN into accepting the commit date from Git.
> if (defined $cmt_date) {
> $cmt_date = strftime("%Y-%m-%dT%H:%M:%S.000000Z", gmtime($cmt_date));
> print "SVN DATE SET TO: $cmt_date\n";
> $ra->change_rev_prop($cmt_rev, 'svn:date', $cmt_date);
> }
1748c1785
< my %log_entry = (log => '', tree => get_tree_from_treeish($treeish));
---
> my %log_entry = (log => '', tree => get_tree_from_treeish($treeish), author =>undef, date => undef);
1758a1796
> my $date;
1764c1802,1805
< $author = $1 if (/^author (.*>)/);
---
> if(/^author (.*>) (\d+) ([\-\+]?\d+)$/o){
> $author = $1;
> $date = $2;
> }
1782a1824,1825
> $log_entry{author} = $author || undef;
> $log_entry{date} = $date || undef;
- 1. git svn dcommit bug id
- 2. 如何撤消git svn dcommit?
- 3. git-svn rebase和dcommit問題
- 4. git-svn dcommit從後提交與Kerberos
- 5. git svn dcommit沒有重定金
- 6. 在git中摘櫻桃後dcommit到SVN
- 7. Git-Svn dcommit導致分支分裂
- 8. git svn dcommit:.DS_Store上的扼流器
- 9. 混帳svn的dcommit失敗
- 10. 混帳SVN dcommit失敗
- 11. 是否有可能使git svn dcommit導致單個svn提交?
- 12. git svn dcommit到sourceforge失敗,但它通過svn直接工作
- 13. 文件夾重命名後的GIT SVN dcommit
- 14. STATUS_ACCESS_VIOLATION與git svn
- 15. git-svn:忽略authorsfile中svn用戶名的大小寫?
- 16. git svn dcommit總是失敗,「無法用髒索引提交。」
- 17. 使用奇數分支結構時Git-svn分支軟管dcommit
- 18. git捆綁與git-svn
- 19. [SVN]:Subversion vs. GIT與其他開源SVN
- 20. 使用git-svn與現有的回購缺乏.git/svn/
- 21. git svn dcommit如何確定在哪裏提交?
- 22. git svn dcommit失敗,「數據不完整:Delta源意外結束」
- 23. git:正確的方式來合併/ rebase相對於svn dcommit
- 24. Git-Svn:保留提交時間戳後dcommit
- 25. git-svn如何知道dcommit要分支到哪個分支?
- 26. 在做git-svn dcommit之前壓縮或編輯一些提交?
- 27. git-svn:分支在svn倉庫中重命名,我如何告訴git-svn?
- 28. git-svn display svn repository url
- 29. git-svn merge 2 svn分支
- 30. 如何複製一個git-svn克隆的存儲庫,以便git svn dcommit仍然可以運行
因此,你只克隆SVN只有一次,並且完成了svn克隆回購的git克隆? – khmarbaise 2011-03-16 16:46:19