LoginSignup
3
1

More than 1 year has passed since last update.

gopkg.inに、プルリク送るときの開発レポジトリ

Last updated at Posted at 2016-10-15

オリジナルの開発自体はGitHubで行われていて、
gopkg.inで管理されてるレポジトリにプルリクを送りたい時に以下のような問題に直面します。

■ 通常のPR

[github.com/go-redis/redis] (https://github.com/go-redis/redis)をforkして、[github.com/yyoshiki41/redis](https://github.com/yyoshiki41/redis)とした場合、
ローカルマシン上の$GOPATH/src/github.com/yyoshiki41/redisディレクトリで開発を行う。

問題点

以下のように開発すると、

$ cd $GOPATH/src/github.com/yyoshiki41/redis
$ vim redis.go

各所に下記のようなimport文があり、自分のレポジトリ下で変更した差分が取り込めない問題に直面します。

import "gopkg.in/redis.v5/internal"

gopkg.in/redis.v5github.com/yyoshiki41/redisに一括置換したりするのもイケていない、
gopkg.in/redis以下で開発してpatchファイル作るとかもイケてない。。

■ 解決策

gopkg.in以下に同期する自分のレポジトリを追加する。」

手順

1. go get

$ go get gopkg.in/ORIGINAL_REPOSITORY

2. GitHub上でfork

https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY をforkして、自分のレポジトリに追加する。

3. 同期するレポジトリを追加

$ cd $GOPATH/src/gopkg.in/ORIGINAL_REPOSITORY
$ git remote -v
origin	https://gopkg.in/ORIGINAL_REPOSITORY (fetch)
origin	https://gopkg.in/ORIGINAL_REPOSITORY (push)
# `myrepo`を追加する
$ git remote add myrepo git@github.com:YOUR_USERNAME/YOUR_FORK
$ git remote -v
myrepo	git@github.com:YOUR_USERNAME/YOUR_FORK (fetch)
myrepo	git@github.com:YOUR_USERNAME/YOUR_FORK (push)
origin	https://gopkg.in/ORIGINAL_REPOSITORY (fetch)
origin	https://gopkg.in/ORIGINAL_REPOSITORY (push)

4. リモートへpush

$ git checkout -b feature
$ git commit -m "Add feature"
$ git push myrepo feature

これで無事、github.com/YOUR_USERNAME/YOUR_FORKへのpushが完了し、プルリクを作成して終わりです。

myrepoの名前はなんでもOKですが、upstreamではないと考え(他の要件での衝突も考え)避けています。

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1