翻译于 2015/01/04 10:08
一个 Github 镜像库建立后会包含两个远端地址:
gitlab git@workbench.dachary.org:tests/testrepo.git (push) origin https://github.com/loic-bot/testrepo (push)
gh (从 ~gitmirrors/repositories/Tests/testrepo 运行) 的命令 github2gitlab 会向github发送pull请求拷贝指定的Github库,然后创建一个合并merge的请求:
$ gh gg --user loic-bot --repo testrepo --number 3
原始的github pull请求
对应的Gitlab合并请求
对每一个pull(拉)请求,github会创建一个refs/pull/N/head 的引用,指向该请求的基点。 (i.e. commit请求会映射到合并的pull请求). github2gitlab 会fetch所有的pull请求:
$ git fetch origin +refs/pull/*:refs/pull/* remote: Counting objects: 5, done. remote: Compressing objects: 100% (3/3), done. remote: Total 5 (delta 1), reused 4 (delta 0) Unpacking objects: 100% (5/5), done. From https://github.com/loic-bot/testrepo * [new ref] refs/pull/1/head -> refs/pull/1/head * [new ref] refs/pull/1/merge -> refs/pull/1/merge * [new ref] refs/pull/2/head -> refs/pull/2/head * [new ref] refs/pull/2/merge -> refs/pull/2/merge
github JSON description of a pull request 包含待合并分支的名字,保存在 pull.head.ref. 通常使用下面的命令在gitlab里面创建分支 :
$ git push gitlab +refs/pull/2/head:refs/heads/dacharypr Counting objects: 3, done. Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To gitlab * [new branch] refs/pull/3/head -> dacharypr
gitlab的pull请求被创建依靠的是pull.head.ref的头部,并且假定gitlab的user/project 完全匹配在pull.base.repo.full_name中找到的github的user/repo。pull在gitlab中被创建总是指向一个基本的引用作为在同一项目中的参考。
合并创建请求可以手动去做,使用 gitlab command line utility ,它包装了node-gitlab library used by github2gitlab:
$ DEBUG='*' gitlab addMergeRequest loic-bot/testrepo dacharypr master null 'dacharypr from github ' gitlab:ApiBase handleOptions() +0ms gitlab:ApiBaseHTTP handleOptions() +1ms gitlab:ApiV3 handleOptions() +0ms gitlab:ApiBase init() +0ms slumber:Serializer constructor +0ms @default=json serializers=null slumber:JsonSerializer constructor +0ms slumber:YamlSerializer constructor +0ms gitlab:ApiBase constructor() +6ms gitlab:Models:ProjectMergeRequests Projects::addMergeRequest() +0ms slumber:api POST +0ms http://workbench.dachary.org/api/v3/projects/loic-bot%2Ftestrepo/merge_requests?private_token=hN4Qssygijhkxs61WL
评论删除后,数据将无法恢复
评论(0)