mirror of
https://github.com/Jguer/yay.git
synced 2025-08-19 05:31:18 +02:00
branchInfo added
This commit is contained in:
parent
c258986edc
commit
b58100fcaf
@ -1,9 +1,13 @@
|
|||||||
package github
|
package github
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// Branches contains the information of a repository branch
|
// Branch contains the information of a repository branch
|
||||||
type Branches []struct {
|
type Branch struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Commit struct {
|
Commit struct {
|
||||||
Sha string `json:"sha"`
|
Sha string `json:"sha"`
|
||||||
@ -11,8 +15,6 @@ type Branches []struct {
|
|||||||
} `json:"commit"`
|
} `json:"commit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const repoAPI = "https://api.github.com/repos/{USER}/{REPOSITORY}/branches"
|
|
||||||
|
|
||||||
func parseSource(source string) (owner string, repo string) {
|
func parseSource(source string) (owner string, repo string) {
|
||||||
split := strings.Split(source, "github.com/")
|
split := strings.Split(source, "github.com/")
|
||||||
if len(split) > 1 {
|
if len(split) > 1 {
|
||||||
@ -28,3 +30,16 @@ func parseSource(source string) (owner string, repo string) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func branchInfo(owner string, repo string) (newRepo []Branch, err error) {
|
||||||
|
url := "https://api.github.com/repos/" + owner + "/" + repo + "/branches"
|
||||||
|
r, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
json.NewDecoder(r.Body).Decode(newRepo)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user