2

私の開発リポジトリであるgitリポジトリがあります。毎週のベースですべての変更を svn リポジトリにアップロードする必要がありますが、自分の git-commit-history を公開したくありません。言い換えれば、私は履歴を失いたいと思っています。特定の週の git リポジトリのすべての変更は、1 つの単一の svn コミットに押しつぶされる必要があります。

1 週間の例:

ギット:

commit 1 "fixed y"
commit 2 "added feature x"
commit 3 "foo"
commit 4 "fixed n"

SVN:

commit 1 "changes from this week"

理想的には、cron ジョブを介して自動的に開始される小さなシェルまたは Python スクリプトによって実行する必要があります。

次の変数があります。

LOCAL_PATH=/tmp/git-svn-bridge/
GIT_DIR=git_repo
SVN_DIR=svn_repo

GIT_REPO_URL=git://git@my_git_server
GIT_REPO_NAME=my_git_repo
GIT_REPO_BRANCH=master

SVN_REPO_URL=svn://my_svn_server
SVN_USER=FIXME
SVN_PASS=FIXME

何か案は?

読んでくれてありがとう!

4

1 に答える 1

0

一般的な考え方は次のとおりです。svn 作業コピーgit archiveをエクスポートしrsync -a --deleteてから更新するために使用します。次のようなもの:

#!/bin/bash -xue

gitdir='/path/to/git/repo-clone/'  
gitbranch='master'

svncodir='/path/to/svn/svn-checkout' 
svnrepo='file:///tmp/svnrepo'  # no trailing slash

# if svn checkout doesn't exit
[[ ! -d $svncodir ]] && svn co $svnrepo $svncodir

# if svn checkout is pointing to a different repo
if svn info $svncodir | grep -qF "URL: $svnrepo"; then
  rm -rf $svncodir
  svn co $svnrepo $svncodir
fi

tmpdest=$(mktemp -d)
git --git-dir $gitdir/.git archive $gitbranch | tar -x -C $tmpdest

cd $svncodir
svn update

# sync our temporary dir with the current svn checkout
rsync -av --delete --force --exclude '.svn' $tmpdest/ .
rm -rf $tmpdest/

# svn add new or modified files
svn add . --force --no-ignore

# remove missing ones (whitespace safe, unless you have
# files with 5 spaces in them)
svn status | awk -F' {5,}' '/!/ {print $2}' | xargs -I'{}' svn rm '{}'

svn status 
svn commit -m "changes from this week"
于 2012-11-09T19:46:00.023 に答える