我试图使用1.0版本的Bitbucket API的previously managed。从gitolite到bitbucket的脚本迁移
我需要从Gitolite迁移到Bitbucket,并且遇到与Bitbucket API v2.0有关的问题。
这里是我的脚本代码:
#!/bin/bash
# Usage: ./bitbucket-migrate.sh repos.txt
#
# repos.txt should have one repository per line.
echo "Reading $1"
while read line
do
repo=$line
echo "###"
echo "Cloning a bare copy of $repo"
git clone --bare [email protected]:$repo
echo "Waiting for clone completion"
sleep 45;
cd $repo.git
echo "Creating repo in Bitbucket"
curl -X POST -v -u [email protected]:password -H "Content-Type: application/json" \ https://api.bitbucket.org/2.0/repositories/teamname/$repo \ -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks"}'
echo "Pushing local mirror to bitbucket"
git push --mirror [email protected]:teamname/$repo.git
echo "Waiting for push completion"
sleep 45;
cd ..
echo "Removing $repo.git"
rm -rf "$repo.git"
echo "Waiting 10 seconds"
echo "###"
sleep 10;
done < $1
exit
此时脚本成功创建一个空的回购协议,而是试图镜子推到位桶时失败。
为了避免副本花费一段时间,我投入了几次延长的睡眠,但我不相信它们会以这种方式产生效果。
这里是收到错误回:
$ git push --mirror [email protected]:teamname/$repo.git
conq: not a git repository.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我需要做的镜子推作为第二API调用?那个电话会是什么样子?我有点迷失在这里。
谢谢!
如果没有更好的答案,那么自学者就是这样。 [http://stackoverflow.com/help/badges/14/self-learner] –