提交 fdb8f69b 编写于 作者: M Mislav Marohnić

Use `project.SameAs(otherProject)` instead of reflect.DeepEqual

This lets github.project implement its own comparison logic. For
instance, two projects can be the same even though their `Protocol`
values don't match.
上级 c9378ca8
......@@ -5,7 +5,6 @@ import (
"github.com/github/hub/github"
"github.com/github/hub/utils"
"os"
"reflect"
)
var cmdFork = &Command{
......@@ -56,7 +55,7 @@ func fork(cmd *Command, args *Args) {
if parent := existingRepo.Parent; parent != nil {
parentURL, _ = github.ParseURL(parent.HTMLURL)
}
if parentURL == nil || !reflect.DeepEqual(parentURL.Project, project) {
if parentURL == nil || !project.SameAs(parentURL.Project) {
err = fmt.Errorf("Error creating fork: %s already exists on %s",
forkProject, forkProject.Host)
utils.Check(err)
......
......@@ -2,7 +2,6 @@ package commands
import (
"fmt"
"reflect"
"regexp"
"strings"
......@@ -126,7 +125,7 @@ func pullRequest(cmd *Command, args *Args) {
// pretend there's no upstream at all
trackedBranch = nil
} else {
if reflect.DeepEqual(baseProject, headProject) && base == trackedBranch.ShortName() {
if baseProject.SameAs(headProject) && base == trackedBranch.ShortName() {
e := fmt.Errorf(`Aborted: head branch is the same as base ("%s")`, base)
e = fmt.Errorf("%s\n(use `-h <branch>` to specify an explicit pull request head)", e)
utils.Check(e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册