Skip to content

Commit

Permalink
allow for branches with slashes in them
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed Jun 28, 2024
1 parent c88b9a9 commit c5441a9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/parsers/azure-devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"path"
"strings"

"github.com/gin-gonic/gin"
"github.com/mcdafydd/go-azuredevops/azuredevops"
Expand Down Expand Up @@ -59,5 +59,5 @@ func (d *Data) azureDevopsDeleted(e *azuredevops.GitPush) bool {
}

func (d *Data) parseBranch(e *azuredevops.GitPush) string {
return path.Base(*e.RefUpdates[0].Name)
return strings.TrimPrefix(*e.RefUpdates[0].Name, prefix)
}
4 changes: 2 additions & 2 deletions lib/parsers/bitbucket-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package parsers

import (
"fmt"
"path"
"strings"

"github.com/gin-gonic/gin"
bitbucketserver "github.com/go-playground/webhooks/v6/bitbucket-server"
Expand Down Expand Up @@ -40,5 +40,5 @@ func (d *Data) bitbucketServerDeleted(c bitbucketserver.RepositoryReferenceChang
}

func (d *Data) bsParseBranch(e bitbucketserver.RepositoryReferenceChangedPayload) string {
return path.Base(e.Changes[0].ReferenceID)
return strings.TrimPrefix(e.Changes[0].ReferenceID, prefix)
}
4 changes: 2 additions & 2 deletions lib/parsers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parsers
import (
"fmt"
"io/ioutil"
"path"
"strings"

"github.com/gin-gonic/gin"
"github.com/google/go-github/v39/github"
Expand All @@ -23,7 +23,7 @@ func (d *Data) parseGithub(c *gin.Context) error {

switch e := event.(type) {
case *github.PushEvent:
d.Branch = path.Base(*e.Ref)
d.Branch = strings.TrimPrefix(*e.Ref, prefix)
d.Deleted = *e.Deleted
d.ModuleName = *e.Repo.Name
d.RepoName = *e.Repo.FullName
Expand Down
4 changes: 2 additions & 2 deletions lib/parsers/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package parsers
import (
"fmt"
"io/ioutil"
"path"
"strings"

"github.com/gin-gonic/gin"
"github.com/xanzy/go-gitlab"
Expand All @@ -22,7 +22,7 @@ func (d *Data) parseGitlab(c *gin.Context) error {

switch e := event.(type) {
case *gitlab.PushEvent:
d.Branch = path.Base(e.Ref)
d.Branch = strings.TrimPrefix(e.Ref, prefix)
d.Deleted = d.gitlabDeleted(e.After)
d.ModuleName = e.Project.Name
d.RepoName = e.Project.PathWithNamespace
Expand Down
2 changes: 2 additions & 0 deletions lib/parsers/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/gin-gonic/gin"
)

const prefix = "refs/heads/"

type Data struct {
Branch string
Deleted bool
Expand Down

0 comments on commit c5441a9

Please sign in to comment.