Use custom github domain for webhook

This commit is contained in:
Vsevolod Strukchinsky 2014-02-09 19:45:15 +06:00
parent 6c9ff00f99
commit 425cbbc324
2 changed files with 8 additions and 9 deletions

View file

@ -87,7 +87,7 @@ func RepoCreateGithub(w http.ResponseWriter, r *http.Request, u *User) error {
return err return err
} }
repo, err := NewGitHubRepo(owner, name, githubRepo.Private) repo, err := NewGitHubRepo(settings.GitHubDomain, owner, name, githubRepo.Private)
if err != nil { if err != nil {
return err return err
} }

View file

@ -12,7 +12,6 @@ const (
) )
const ( const (
HostGithub = "github.com"
HostBitbucket = "bitbucket.org" HostBitbucket = "bitbucket.org"
HostGoogle = "code.google.com" HostGoogle = "code.google.com"
HostCustom = "custom" HostCustom = "custom"
@ -25,8 +24,8 @@ const (
) )
const ( const (
githubRepoPattern = "git://github.com/%s/%s.git" githubRepoPattern = "git://%s/%s/%s.git"
githubRepoPatternPrivate = "git@github.com:%s/%s.git" githubRepoPatternPrivate = "git@%s:%s/%s.git"
bitbucketRepoPattern = "https://bitbucket.org/%s/%s.git" bitbucketRepoPattern = "https://bitbucket.org/%s/%s.git"
bitbucketRepoPatternPrivate = "git@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 // 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 var url string
switch private { switch private {
case false: case false:
url = fmt.Sprintf(githubRepoPattern, owner, name) url = fmt.Sprintf(githubRepoPattern, domain, owner, name)
case true: 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 // Creates a new Bitbucket repository
@ -142,7 +141,7 @@ func NewBitbucketRepo(owner, name string, private bool) (*Repo, error) {
case true: case true:
url = fmt.Sprintf(bitbucketRepoPatternPrivate, owner, name) 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 { func (r *Repo) DefaultBranch() string {