从gitolite到bitbucket的脚本化迁移
我尝试的是使用1.0版本的Bitbucket API 我需要从Gitolite迁移到Bitbucket,并且Bitbucket API的v2.0存在问题 以下是我的脚本代码:从gitolite到bitbucket的脚本化迁移,git,bitbucket,bitbucket-api,Git,Bitbucket,Bitbucket Api,我尝试的是使用1.0版本的Bitbucket API 我需要从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
#!/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 git@git.company.com:$repo
echo "Waiting for clone completion"
sleep 45;
cd $repo.git
echo "Creating repo in Bitbucket"
curl -X POST -v -u username@company.com: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 git@bitbucket.org: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
我是否需要将镜像推送作为第二个API调用?那个电话是什么样子的?我在这里有点迷路了
谢谢 我要回答我自己的问题![主饶恕我] 我发出的API请求确实创建了存储库,但JSON中断,它没有读取我传入的参数 因此,Bitbucket使用默认的hg而不是git创建了回购协议,这导致了我在尝试将镜像推送到回购协议时看到的错误 我最终手动删除了使用早期请求创建的第一个回购,并在Bitbucket UI中将其手动重新创建为git回购,这将我的帐户默认设置为git(因为它自动默认为使用的最后一个回购类型)
完成后,我就可以使用--mirror将其推送到存储库了。脚本的后续运行对我来说很有效,因为它创建了带有默认值(现在设置为git)的回购协议,并且能够正确地推送。如果没有更好的答案,那么自我学习就是一件很重要的事情。[
$ git push --mirror git@bitbucket.org: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.