github.go 677 B

123456789101112131415161718192021222324252627282930
  1. package github
  2. import "strings"
  3. // Branches contains the information of a repository branch
  4. type Branches []struct {
  5. Name string `json:"name"`
  6. Commit struct {
  7. Sha string `json:"sha"`
  8. URL string `json:"url"`
  9. } `json:"commit"`
  10. }
  11. const repoAPI = "https://api.github.com/repos/{USER}/{REPOSITORY}/branches"
  12. func parseSource(source string) (owner string, repo string) {
  13. split := strings.Split(source, "github.com/")
  14. if len(split) > 1 {
  15. secondSplit := strings.Split(split[1], "/")
  16. if len(secondSplit) > 1 {
  17. owner = secondSplit[0]
  18. thirdSplit := strings.Split(secondSplit[1], ".git")
  19. if len(thirdSplit) > 0 {
  20. repo = thirdSplit[0]
  21. }
  22. }
  23. }
  24. return
  25. }