Skip to content

Commit 526812c

Browse files
committed
feat(handler): Detect gitlab repos
1 parent 682d637 commit 526812c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

handler.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ func newHandler(config []byte) (*handler, error) {
6868
display: e.Display,
6969
vcs: e.VCS,
7070
}
71+
isGithub := strings.HasPrefix(e.Repo, "https://github.com/")
72+
isGitlab := strings.HasPrefix(e.Repo, "https://gitlab.com/")
7173
switch {
7274
case e.Display != "":
7375
// Already filled in.
74-
case strings.HasPrefix(e.Repo, "https://github.com/"):
76+
case isGithub, isGitlab:
7577
pc.display = fmt.Sprintf("%v %v/tree/master{/dir} %v/blob/master{/dir}/{file}#L{line}", e.Repo, e.Repo, e.Repo)
7678
case strings.HasPrefix(e.Repo, "https://bitbucket.org"):
7779
pc.display = fmt.Sprintf("%v %v/src/default{/dir} %v/src/default{/dir}/{file}#{file}-{line}", e.Repo, e.Repo, e.Repo)
@@ -82,7 +84,7 @@ func newHandler(config []byte) (*handler, error) {
8284
if e.VCS != "bzr" && e.VCS != "git" && e.VCS != "hg" && e.VCS != "svn" {
8385
return nil, fmt.Errorf("configuration for %v: unknown VCS %s", path, e.VCS)
8486
}
85-
case strings.HasPrefix(e.Repo, "https://github.com/"):
87+
case isGithub, isGitlab:
8688
pc.vcs = "git"
8789
default:
8890
return nil, fmt.Errorf("configuration for %v: cannot infer VCS from %s", path, e.Repo)

0 commit comments

Comments
 (0)