Add SHA to versions
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
# GitLab Releases Resource
|
||||
|
||||
Fetches and creates versioned GitLab resources. GitLab resources are metadata attached to tags.
|
||||
Fetches and creates versioned GitLab resources. GitLab resources are metadata attached to tags. Note that `check` will skip tags that do not have associated resources.
|
||||
|
||||
Note that this is still in development, and is still undergoing changes. It may or may not work properly at the moment, but should hopefully somewhat more stable soon.
|
||||
Note that this is still in development, and is still undergoing changes. It may or may not work properly at the moment, but should hopefully be somewhat more stable soon.
|
||||
|
||||
You may want to clean up your uploads folder over time if you re-run a put step with the same inputs, as this will simply re-upload the files under a new hash.
|
||||
|
||||
## Source Configuration
|
||||
|
||||
|
@@ -74,9 +74,7 @@ func (c *CheckCommand) Run(request CheckRequest) ([]Version, error) {
|
||||
latestTag := filteredTags[len(filteredTags)-1]
|
||||
|
||||
if (request.Version == Version{}) {
|
||||
return []Version{
|
||||
Version{Tag: latestTag.Name},
|
||||
}, nil
|
||||
return []Version{versionFromTag(latestTag)}, nil
|
||||
}
|
||||
|
||||
if latestTag.Name == request.Version.Tag {
|
||||
@@ -84,11 +82,11 @@ func (c *CheckCommand) Run(request CheckRequest) ([]Version, error) {
|
||||
// https://github.com/concourse/github-release-resource/blob/master/check_command.go#L87
|
||||
// but documentation says to return current item?
|
||||
// https://concourse-ci.org/implementing-resources.html#section_resource-check
|
||||
return []Version{Version{Tag: latestTag.Name}}, nil
|
||||
return []Version{versionFromTag(latestTag)}, nil
|
||||
}
|
||||
|
||||
upToLatest := false
|
||||
reversedVersions := []Version{}
|
||||
nextVersions := []Version{} // contains the requested version and all newer ones
|
||||
|
||||
for _, release := range filteredTags {
|
||||
if !upToLatest {
|
||||
@@ -97,17 +95,17 @@ func (c *CheckCommand) Run(request CheckRequest) ([]Version, error) {
|
||||
}
|
||||
|
||||
if upToLatest {
|
||||
reversedVersions = append(reversedVersions, Version{Tag: release.Name})
|
||||
nextVersions = append(nextVersions, Version{Tag: release.Name})
|
||||
}
|
||||
}
|
||||
|
||||
if !upToLatest {
|
||||
// current version was removed; start over from latest
|
||||
reversedVersions = append(
|
||||
reversedVersions,
|
||||
Version{Tag: filteredTags[len(filteredTags)-1].Name},
|
||||
nextVersions = append(
|
||||
nextVersions,
|
||||
versionFromTag(filteredTags[len(filteredTags)-1]),
|
||||
)
|
||||
}
|
||||
|
||||
return reversedVersions, nil
|
||||
return nextVersions, nil
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@ func (c *InCommand) Run(destDir string, request InRequest) (InResponse, error) {
|
||||
}
|
||||
|
||||
return InResponse{
|
||||
Version: Version{Tag: foundTag.Name},
|
||||
Version: versionFromTag(foundTag),
|
||||
Metadata: metadataFromTag(foundTag),
|
||||
}, nil
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
|
||||
}
|
||||
|
||||
return OutResponse{
|
||||
Version: Version{Tag: tag_name},
|
||||
Version: versionFromTag(tag),
|
||||
Metadata: metadataFromTag(tag),
|
||||
}, nil
|
||||
}
|
||||
|
@@ -69,7 +69,7 @@ type OutResponse struct {
|
||||
|
||||
type Version struct {
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Commitish string `json:"commitish,omitempty"`
|
||||
CommitSHA string `json:"commit_sha,omitempty"`
|
||||
}
|
||||
|
||||
type MetadataPair struct {
|
||||
|
@@ -2,6 +2,8 @@ package resource
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/xanzy/go-gitlab"
|
||||
)
|
||||
|
||||
var defaultTagFilter = "^v?([^v].*)"
|
||||
@@ -28,3 +30,10 @@ func (vp *versionParser) parse(tag string) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func versionFromTag(tag *gitlab.Tag) Version {
|
||||
return Version{
|
||||
Tag: tag.Name,
|
||||
CommitSHA: tag.Commit.ID,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user