git-svn具有严格的权限 [英] git-svn with strict permission

查看:168
本文介绍了git-svn具有严格的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个不受我控制的svn存储库。它使用一个标准的布局,拥有非常严格的权限。



我没有读取父文件夹的权限。

  svn://foo.bar/project/ 
svn://foo.bar/project/branches

但是我可以阅读 svn://foo.bar/project/trunk svn ://foo.bar/project/branches/x



如果我用git-svn使用多个遥控器,我可以提取并提交这些分支。但是git-svn不会找到分支的父项。多个遥控器将被视为不同的存储库。



看来我可以修改git-svn来纠正后面的父源。但我不知道Perl。
是否可以编写脚本修复分支的父散列。或者我可以使用一个简单的脚本创建新的远程分支,然后让git-svn来获取它。 我写了一个简单的肮脏的shell脚本来初始化新的分支。它将为svn分支创建第一个提交。之后, git-svn fetch --all 就可以工作了。

 <!c $ c>#!/ bin / bash 

branch = $ 1
prefix = svn-remote.svn- $ branch
rooturl = svn://示例。 com
branchurl = $ rooturl / foo / branches
git config $ prefix.ignore -path^ exclude
git config $ prefix.url $ branchurl / $ branch
git config $ prefix.fetch:refs / remotes / $ branch
$ b $ logentry = $(svn log -v -r0:HEAD - 停止复制-l 1 --xml $ branchurl / $ branch)
torev = $(echo$ logentry| grep revision | grep -o [0-9] *)
fromrev = $(echo$ logentry| grep copyfrom-rev | grep -o [ 0-9] *)
frompath = $(echo$ logentry| grep copyfrom-path | sed -E's / \s * copyfrom-path =(。*)/ \ 1 / ')
author = $(echo$ logentry| grep< author>| sed -E's#< /?author> ## g')
author_date = $(echo $ logentry| grep< date>| sed -E's#< /?date> ## g')

if [-z $ torev]; then
出口1;
fi

if [-z $ fromrev];然后
exit 2;
fi

if [-z $ frompath];然后
exit 3;
fi

fromurl = $ rooturl $ frompath @ $ fromrev
tourl = $ branchurl / $ branch @ $ torev
frombranch = $(basename $ frompath)
echo $ fromurl
echo $ tourl
echo $ fromrev
parent = $(git svn log -r $ fromrev $ frombranch --oneline --show-commit | grep $ fromrev | awk '{print $ 3}')
if [-z $ parent];然后
exit 4;
fi
uuid = $(git log -1 | grep git-svn-id:| awk'{print $ NF}')
tree = $(git cat-file commit $ parent | head -1 | cut -d''-f 2)
echo tree $ tree
echo父母
echo uuid $ uuid

head = $( GIT_AUTHOR_NAME = $ author GIT_AUTHOR_EMAIL = $ author @ $ uuid GIT_AUTHOR_DATE = $ author_date git commit-tree $ tree -p $ parent<< EOF
$ logentry

git-svn-id: $ tourl $ uuid
EOF

echo $ head
git update-ref refs / remotes / $ branch $ head


I am working on a svn repository out of my control. It uses a standard layout with very strict permissions.

I have't read permission to the parent folder.

svn://foo.bar/project/
svn://foo.bar/project/branches

But I can read svn://foo.bar/project/trunk and svn://foo.bar/project/branches/x.

If I use multiple remotes with git-svn, I can fetch and commit these branches. But the git-svn will not find the branch's parent. Multiple remotes will be treated as different repositories.

It seems I can modify the git-svn to correct the follow parent source. But I don't known perl. Is it possible to write a script fix the branch's parent hash. Or can I use a simple script to create new remote branch then let git-svn to fetch it.

解决方案

I wrote a simple dirty shell script to init the new branch.It will create the first commit for the svn branch. After that the git-svn fetch --all will work.

#!/bin/bash

branch=$1
prefix=svn-remote.svn-$branch
rooturl=svn://example.com
branchurl=$rooturl/foo/branches
git config $prefix.ignore-paths "^exclude"
git config $prefix.url $branchurl/$branch
git config $prefix.fetch :refs/remotes/$branch

logentry=$(svn log -v -r0:HEAD --stop-on-copy -l 1 --xml $branchurl/$branch)
torev=$(echo "$logentry" |grep revision |grep -o [0-9]*)
fromrev=$(echo "$logentry" |grep copyfrom-rev |grep -o [0-9]*)
frompath=$(echo "$logentry" |grep copyfrom-path | sed -E 's/\s*copyfrom-path="(.*)"/\1/')
author=$(echo "$logentry" |grep "<author>" |sed -E 's#</?author>##g')
author_date=$(echo "$logentry" |grep "<date>" |sed -E 's#</?date>##g')

if [ -z $torev ];then
    exit 1;
fi

if [ -z $fromrev ];then
    exit 2;
fi

if [ -z $frompath ];then
    exit 3;
fi

fromurl=$rooturl$frompath@$fromrev
tourl=$branchurl/$branch@$torev
frombranch=$(basename $frompath )
echo $fromurl
echo $tourl
echo $fromrev
parent=$(git svn log -r $fromrev $frombranch --oneline --show-commit |grep $fromrev |awk '{print $3}')
if [ -z $parent ];then
    exit 4;
fi
uuid=$(git log -1 |grep git-svn-id: | awk '{print $NF}')
tree=$(git cat-file commit $parent |head -1 |cut  -d ' ' -f 2)
echo tree $tree
echo parent $parent
echo uuid $uuid

head=$(GIT_AUTHOR_NAME=$author GIT_AUTHOR_EMAIL=$author@$uuid GIT_AUTHOR_DATE=$author_date git commit-tree $tree -p $parent <<EOF
$logentry

git-svn-id: $tourl $uuid 
EOF
)
echo $head
git update-ref refs/remotes/$branch $head

这篇关于git-svn具有严格的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆