如何将 Git 服务器存储库问题推送到 Git 集线器存储库?
How to push a Git server repository issues to Github repository?
我在 Git 服务器 上有一个存储库,就像 Bitbucket and now I want to switch to Github. So I make a copy of my repository on the Github successfully, but the my repository issues (Nearly 200 issue) not copied on the Github 存储库一样!
存在一种无需手动逐一插入即可复制 Github 存储库中所有问题的方法!?
As has said above you can use the BitBucket API to retrieve your current list of issues, or details on a specific issue. Have a look at https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs for more info on this. In a nutshell, you can make a request to https://api.bitbucket.org/2.0/repositories/<repo-owner-username>/<repo-name>/issues/<ID>
and get back a JSON response of the issue details. You can go to https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/issues/1 在您的浏览器中查看响应的示例。
由于您不想迁移所有问题,因此您可以重复向 https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/issues/<ID>
发出请求,其中 ID 的范围从 1 到您有多少问题。
获得现有问题的详细信息后,您需要编写一些代码来解析 JSON,然后使用 BitBucket 提供的信息向 GitHub 的 API 创建新问题。
您可以在 https://developer.github.com/v3/issues/#create-an-issue 上阅读 GitHub 的 API。基本上为此,您将向 https://api.github.com/repos/<repo-owner-username>/<repo-name>/issues
发出 POST
请求,并随请求提供必要的参数。具体如何执行此操作将取决于您用来发出请求的库。使用 CURL,请求可能看起来像 curl -H "Content-Type: application/json" -X POST -d '{"title":"Found an issue","body":"I'm having a problem with this."}' https://api.github.com/repos/behzad-khosravifar/myRepo/issues
.
所以将它们放在一起 pseudocode 可能看起来像:
for (id = 1 to 100)
issueRawData = http_get('https://api.bitbucket.org/2.0/repositories/<owner>/<repo>/issues/'+id)
issueJson = JSON.parse(issueRawData);
postData = { "title" : issue.title, "body" : issue.content.raw }
http_post('https://api.github.com/repos/<repo-owner-username>/<repo-name>/issues/'+id, postData)
}
额外内容和陷阱
- 遍历所有问题将意味着您将根据 BitBucket 中已关闭的问题在 GitHub 中创建问题。您可以检查从 BitBucket 返回的 'state' 字段,以有条件地在 GitHub 中创建问题。或者无论如何创建问题,然后在创建问题后使用 GitHub 的 API 关闭问题。
- 您需要使用 GitHub(可能还有 BitBucket)进行身份验证。 https://developer.github.com/v3/auth/ 详细说明了如何在 GitHub 中创建问题时提供身份验证详细信息。
我在 Git 服务器 上有一个存储库,就像 Bitbucket and now I want to switch to Github. So I make a copy of my repository on the Github successfully, but the my repository issues (Nearly 200 issue) not copied on the Github 存储库一样!
存在一种无需手动逐一插入即可复制 Github 存储库中所有问题的方法!?
As https://api.bitbucket.org/2.0/repositories/<repo-owner-username>/<repo-name>/issues/<ID>
and get back a JSON response of the issue details. You can go to https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/issues/1 在您的浏览器中查看响应的示例。
由于您不想迁移所有问题,因此您可以重复向 https://api.bitbucket.org/2.0/repositories/tutorials/tutorials.bitbucket.org/issues/<ID>
发出请求,其中 ID 的范围从 1 到您有多少问题。
获得现有问题的详细信息后,您需要编写一些代码来解析 JSON,然后使用 BitBucket 提供的信息向 GitHub 的 API 创建新问题。
您可以在 https://developer.github.com/v3/issues/#create-an-issue 上阅读 GitHub 的 API。基本上为此,您将向 https://api.github.com/repos/<repo-owner-username>/<repo-name>/issues
发出 POST
请求,并随请求提供必要的参数。具体如何执行此操作将取决于您用来发出请求的库。使用 CURL,请求可能看起来像 curl -H "Content-Type: application/json" -X POST -d '{"title":"Found an issue","body":"I'm having a problem with this."}' https://api.github.com/repos/behzad-khosravifar/myRepo/issues
.
所以将它们放在一起 pseudocode 可能看起来像:
for (id = 1 to 100)
issueRawData = http_get('https://api.bitbucket.org/2.0/repositories/<owner>/<repo>/issues/'+id)
issueJson = JSON.parse(issueRawData);
postData = { "title" : issue.title, "body" : issue.content.raw }
http_post('https://api.github.com/repos/<repo-owner-username>/<repo-name>/issues/'+id, postData)
}
额外内容和陷阱
- 遍历所有问题将意味着您将根据 BitBucket 中已关闭的问题在 GitHub 中创建问题。您可以检查从 BitBucket 返回的 'state' 字段,以有条件地在 GitHub 中创建问题。或者无论如何创建问题,然后在创建问题后使用 GitHub 的 API 关闭问题。
- 您需要使用 GitHub(可能还有 BitBucket)进行身份验证。 https://developer.github.com/v3/auth/ 详细说明了如何在 GitHub 中创建问题时提供身份验证详细信息。