From 425cbbc32432c9c10884b7b65798d2e7d2397f4a Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Sun, 9 Feb 2014 19:45:15 +0600 Subject: [PATCH] Use custom github domain for webhook --- pkg/handler/repos.go | 2 +- pkg/model/repo.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/handler/repos.go b/pkg/handler/repos.go index 65f49073..53801244 100644 --- a/pkg/handler/repos.go +++ b/pkg/handler/repos.go @@ -87,7 +87,7 @@ func RepoCreateGithub(w http.ResponseWriter, r *http.Request, u *User) error { return err } - repo, err := NewGitHubRepo(owner, name, githubRepo.Private) + repo, err := NewGitHubRepo(settings.GitHubDomain, owner, name, githubRepo.Private) if err != nil { return err } diff --git a/pkg/model/repo.go b/pkg/model/repo.go index 5b89ad71..bf47b5ef 100644 --- a/pkg/model/repo.go +++ b/pkg/model/repo.go @@ -12,7 +12,6 @@ const ( ) const ( - HostGithub = "github.com" HostBitbucket = "bitbucket.org" HostGoogle = "code.google.com" HostCustom = "custom" @@ -25,8 +24,8 @@ const ( ) const ( - githubRepoPattern = "git://github.com/%s/%s.git" - githubRepoPatternPrivate = "git@github.com:%s/%s.git" + githubRepoPattern = "git://%s/%s/%s.git" + githubRepoPatternPrivate = "git@%s:%s/%s.git" bitbucketRepoPattern = "https://bitbucket.org/%s/%s.git" bitbucketRepoPatternPrivate = "git@bitbucket.org:%s/%s.git" ) @@ -122,15 +121,15 @@ func NewRepo(host, owner, name, scm, url string) (*Repo, error) { } // Creates a new GitHub repository -func NewGitHubRepo(owner, name string, private bool) (*Repo, error) { +func NewGitHubRepo(domain, owner, name string, private bool) (*Repo, error) { var url string switch private { case false: - url = fmt.Sprintf(githubRepoPattern, owner, name) + url = fmt.Sprintf(githubRepoPattern, domain, owner, name) case true: - url = fmt.Sprintf(githubRepoPatternPrivate, owner, name) + url = fmt.Sprintf(githubRepoPatternPrivate, domain, owner, name) } - return NewRepo(HostGithub, owner, name, ScmGit, url) + return NewRepo(domain, owner, name, ScmGit, url) } // Creates a new Bitbucket repository @@ -142,7 +141,7 @@ func NewBitbucketRepo(owner, name string, private bool) (*Repo, error) { case true: url = fmt.Sprintf(bitbucketRepoPatternPrivate, owner, name) } - return NewRepo(HostGithub, owner, name, ScmGit, url) + return NewRepo(HostBitbucket, owner, name, ScmGit, url) } func (r *Repo) DefaultBranch() string {