Pass on github client error, do not create empty commit_sha file
This commit is contained in:
@@ -63,11 +63,17 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commitPath := filepath.Join(destDir, "commit_sha")
|
commitPath := filepath.Join(destDir, "commit_sha")
|
||||||
commitSHA = c.resolveTagToCommitSHA(*foundRelease.TagName)
|
commitSHA, err = c.resolveTagToCommitSHA(*foundRelease.TagName)
|
||||||
|
if err != nil {
|
||||||
|
return InResponse{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if commitSHA != "" {
|
||||||
err = ioutil.WriteFile(commitPath, []byte(commitSHA), 0644)
|
err = ioutil.WriteFile(commitPath, []byte(commitSHA), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return InResponse{}, err
|
return InResponse{}, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if foundRelease.Body != nil && *foundRelease.Body != "" {
|
if foundRelease.Body != nil && *foundRelease.Body != "" {
|
||||||
body := *foundRelease.Body
|
body := *foundRelease.Body
|
||||||
@@ -191,18 +197,13 @@ func (c *InCommand) downloadFile(url, destPath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InCommand) resolveTagToCommitSHA(tag string) string {
|
func (c *InCommand) resolveTagToCommitSHA(tag string) (string, error) {
|
||||||
reference, err := c.github.GetRef(tag)
|
reference, err := c.github.GetRef(tag)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil && *reference.Object.Type != "commit" {
|
||||||
fmt.Fprintln(c.writer, "could not resolve tag '%s' to commit: %v", tag, err)
|
fmt.Fprintln(c.writer, "could not resolve tag '%s' to commit: returned type is not 'commit' - only lightweight tags are supported")
|
||||||
return ""
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if *reference.Object.Type != "commit" {
|
return *reference.Object.SHA, err
|
||||||
fmt.Fprintln(c.writer, "could not resolve tag '%s' to commit: returned type is not 'commit' - only lightweight tags are supported", tag)
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return *reference.Object.SHA
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user