1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
This commit is contained in:
Craig Peterson
2017-04-19 15:38:14 -06:00
parent db6e094aba
commit ef4897d893

View File

@@ -37,20 +37,20 @@ func main() {
} }
c := github.NewClient(oauth2.NewClient(bg(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: tok}))) c := github.NewClient(oauth2.NewClient(bg(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: tok})))
log.Println("Getting release info")
rel, _, err := c.Repositories.GetReleaseByTag(bg(), owner, repo, tag)
check(err)
for _, f := range files { for _, f := range files {
log.Printf("--- %s", f) log.Printf("--- %s", f)
log.Println("Getting release info")
rel, _, err := c.Repositories.GetReleaseByTag(bg(), owner, repo, tag)
check(err)
var found *github.ReleaseAsset var found *github.ReleaseAsset
var foundOld *github.ReleaseAsset var foundOld *github.ReleaseAsset
for _, ass := range rel.Assets { for _, ass := range rel.Assets {
if ass.GetName() == f { if ass.GetName() == f {
found = &ass found = &ass
} }
if ass.GetName()+".old" == f { if ass.GetName() == f+".old" {
foundOld = &ass foundOld = &ass
} }
} }
@@ -60,13 +60,12 @@ func main() {
if found != nil { if found != nil {
n := found.GetName() + ".old" n := found.GetName() + ".old"
found.Name = &n found.Name = &n
log.Println("Renaming old asset") log.Printf("Renaming old asset %s(%d) to .old", found.GetName(), found.GetID())
log.Println(found.GetName(), found.GetID())
_, _, err = c.Repositories.EditReleaseAsset(bg(), owner, repo, found.GetID(), found) _, _, err = c.Repositories.EditReleaseAsset(bg(), owner, repo, found.GetID(), found)
check(err) check(err)
} }
log.Println("Uploading new file") log.Printf("Uploading new file %s", f)
upOpts := &github.UploadOptions{} upOpts := &github.UploadOptions{}
upOpts.Name = f upOpts.Name = f
f, err := os.Open(f) f, err := os.Open(f)
@@ -82,11 +81,6 @@ func main() {
} }
log.Println("Editing release body") log.Println("Editing release body")
log.Println("Getting release info")
rel, _, err := c.Repositories.GetReleaseByTag(bg(), owner, repo, tag)
check(err)
body := strings.TrimSpace(rel.GetBody()) body := strings.TrimSpace(rel.GetBody())
lines := strings.Split(body, "\n") lines := strings.Split(body, "\n")
last := lines[len(lines)-1] last := lines[len(lines)-1]