This commit is contained in:
Jingwen Owen Ou 2013-07-20 07:41:43 -07:00
Родитель 942d996910
Коммит c4de7b63b9
3 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -1,7 +1,6 @@
package commands package commands
import ( import (
"fmt"
"github.com/jingweno/gh/github" "github.com/jingweno/gh/github"
"regexp" "regexp"
) )
@ -64,7 +63,7 @@ func parseCherryPickProjectAndSha(ref string) (project *github.Project, sha stri
} }
} }
ownerWithShaRegexp := regexp.MustCompile(fmt.Sprintf("^(%s)@([a-f0-9]{7,40})$")) ownerWithShaRegexp := regexp.MustCompile("^(%s)@([a-f0-9]{7,40})$")
if ownerWithShaRegexp.MatchString(ref) { if ownerWithShaRegexp.MatchString(ref) {
matches := ownerWithShaRegexp.FindStringSubmatch(ref) matches := ownerWithShaRegexp.FindStringSubmatch(ref)
sha = matches[2] sha = matches[2]

Просмотреть файл

@ -24,7 +24,7 @@ func (gh *GitHub) PullRequest(id string) (*octokat.PullRequest, error) {
func (gh *GitHub) CreatePullRequest(base, head, title, body string) (string, error) { func (gh *GitHub) CreatePullRequest(base, head, title, body string) (string, error) {
client := gh.client() client := gh.client()
params := octokat.PullRequestParams{base, head, title, body} params := octokat.PullRequestParams{Base: base, Head: head, Title: title, Body: body}
pullRequest, err := client.CreatePullRequest(gh.repo(), params) pullRequest, err := client.CreatePullRequest(gh.repo(), params)
if err != nil { if err != nil {
return "", err return "", err
@ -36,7 +36,7 @@ func (gh *GitHub) CreatePullRequest(base, head, title, body string) (string, err
func (gh *GitHub) Repository(project Project) (*octokat.Repository, error) { func (gh *GitHub) Repository(project Project) (*octokat.Repository, error) {
client := gh.client() client := gh.client()
return client.Repository(octokat.Repo{project.Name, project.Owner}) return client.Repository(octokat.Repo{Name: project.Name, UserName: project.Owner})
} }
// TODO: detach GitHub from Project // TODO: detach GitHub from Project
@ -59,7 +59,7 @@ func (gh *GitHub) CreateRepository(project Project, description, homepage string
func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (string, error) { func (gh *GitHub) CreatePullRequestForIssue(base, head, issue string) (string, error) {
client := gh.client() client := gh.client()
params := octokat.PullRequestForIssueParams{base, head, issue} params := octokat.PullRequestForIssueParams{Base: base, Head: head, Issue: issue}
pullRequest, err := client.CreatePullRequestForIssue(gh.repo(), params) pullRequest, err := client.CreatePullRequestForIssue(gh.repo(), params)
if err != nil { if err != nil {
return "", err return "", err
@ -85,14 +85,14 @@ func (gh *GitHub) CiStatus(sha string) (*octokat.Status, error) {
func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (repo *octokat.Repository, err error) { func (gh *GitHub) ForkRepository(name, owner string, noRemote bool) (repo *octokat.Repository, err error) {
client := gh.client() client := gh.client()
config := gh.Config config := gh.Config
repo, err = client.Repository(octokat.Repo{name, config.User}) repo, err = client.Repository(octokat.Repo{Name: name, UserName: config.User})
if repo != nil && err == nil { if repo != nil && err == nil {
msg := fmt.Sprintf("Error creating fork: %s exists on %s", repo.FullName, GitHubHost) msg := fmt.Sprintf("Error creating fork: %s exists on %s", repo.FullName, GitHubHost)
err = errors.New(msg) err = errors.New(msg)
return return
} }
repo, err = client.Fork(octokat.Repo{name, owner}, nil) repo, err = client.Fork(octokat.Repo{Name: name, UserName: owner}, nil)
return return
} }
@ -109,7 +109,7 @@ func (gh *GitHub) ExpandRemoteUrl(owner, name string, isSSH bool) (url string) {
func (gh *GitHub) repo() octokat.Repo { func (gh *GitHub) repo() octokat.Repo {
project := gh.Project project := gh.Project
return octokat.Repo{project.Name, project.Owner} return octokat.Repo{Name: project.Name, UserName: project.Owner}
} }
func findOrCreateToken(user, password string) (string, error) { func findOrCreateToken(user, password string) (string, error) {

Просмотреть файл

@ -7,7 +7,7 @@ import (
) )
func main() { func main() {
runner := commands.Runner{os.Args[1:]} runner := commands.Runner{Args: os.Args[1:]}
err := runner.Execute() err := runner.Execute()
utils.Check(err) utils.Check(err)
} }