Exemplo n.º 1
0
Arquivo: main.go Projeto: koron/upvim
func determineSourceURL(c *config) (string, error) {
	r, err := github.Latest("vim", "vim-win32-installer")
	if err != nil {
		return "", err
	}
	if r.Draft || r.PreRelease {
		return "", errors.New("absence of proper latest release")
	}
	var target *github.Asset
	for _, a := range r.Assets {
		if !strings.HasPrefix(a.Name, "gvim_7.4.") {
			continue
		}
		if (c.cpu == arch.X86 && strings.HasSuffix(a.Name, "_x86.zip")) ||
			(c.cpu == arch.AMD64 && strings.HasSuffix(a.Name, "_x64.zip")) {
			target = &a
			break
		}
	}
	if target == nil {
		return "", errors.New("no assets for arch in latest release")
	}
	if target.State != "uploaded" {
		return "", fmt.Errorf("new release's status error: %s", target.State)
	}
	prev_anchor, err := c.anchor()
	if err != nil {
		return "", err
	}
	fmt.Printf("prev: %s\nupdated: %s\nbefore: %v\n", prev_anchor, target.UpdatedAt, prev_anchor.Before(target.UpdatedAt))
	if prev_anchor.After(target.UpdatedAt) {
		return "", errors.New("no updated assets in release")
	}
	return target.DownloadURL, nil
}
Exemplo n.º 2
0
func main() {
	r, err := github.Latest("vim", "vim-win32-installer")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%#v", r)
}