Auto-update dependencies (#74)

Produced via:
  `dep ensure -update knative.dev/test-infra knative.dev/pkg`
/assign @mattmoor
This commit is contained in:
mattmoor-sockpuppet 2019-08-15 21:17:08 -07:00 committed by Knative Prow Robot
parent 62f489e186
commit 2e1a1d12d1
5 changed files with 19 additions and 14 deletions

6
Gopkg.lock generated
View File

@ -927,7 +927,7 @@
[[projects]]
branch = "master"
digest = "1:4ad65001bd7667eebd1c0e32c4c166cad0ddbc71015195887f9942458ff19012"
digest = "1:9d7c900ebc70071471915d9cb9eecc67039ded90c553bfb985a45c06555ff864"
name = "knative.dev/pkg"
packages = [
"apis",
@ -946,7 +946,7 @@
"metrics/metricskey",
]
pruneopts = "T"
revision = "d3c17af1d97a4dd7f0167628df312f1e9889f444"
revision = "7e6f1f48c9c4cdb1a3a09628986e7e706c82ceab"
[[projects]]
branch = "master"
@ -957,7 +957,7 @@
"tools/dep-collector",
]
pruneopts = "UT"
revision = "aa17edaa3b0d03edfb5c9cba8422e8151d759fad"
revision = "3543363d1b8d074deaa57081a53af9113074eeda"
[solve-meta]
analyzer-name = "dep"

View File

@ -30,9 +30,7 @@ const (
koDataPathEnvName = "KO_DATA_PATH"
)
var (
commitIDRE = regexp.MustCompile(`^[a-f0-9]{40}$`)
)
var commitIDRE = regexp.MustCompile(`^[a-f0-9]{40}$`)
// Get tries to fetch the first 7 digitals of GitHub commit ID from HEAD file in
// KO_DATA_PATH. If it fails, it returns the error it gets.
@ -42,11 +40,17 @@ func Get() (string, error) {
return "", err
}
commitID := strings.TrimSpace(string(data))
if !commitIDRE.MatchString(commitID) {
err := fmt.Errorf("%q is not a valid GitHub commit ID", commitID)
return "", err
if rID := strings.TrimPrefix(commitID, "ref: "); rID != commitID {
data, err := readFileFromKoData(rID)
if err != nil {
return "", err
}
commitID = strings.TrimSpace(string(data))
}
return string(commitID[0:7]), nil
if commitIDRE.MatchString(commitID) {
return commitID[:7], nil
}
return "", fmt.Errorf("%q is not a valid GitHub commit ID", commitID)
}
// readFileFromKoData tries to read data as string from the file with given name
@ -56,9 +60,7 @@ func Get() (string, error) {
func readFileFromKoData(filename string) ([]byte, error) {
koDataPath := os.Getenv(koDataPathEnvName)
if koDataPath == "" {
err := fmt.Errorf("%q does not exist or is empty", koDataPathEnvName)
return nil, err
return nil, fmt.Errorf("%q does not exist or is empty", koDataPathEnvName)
}
fullFilename := filepath.Join(koDataPath, filename)
return ioutil.ReadFile(fullFilename)
return ioutil.ReadFile(filepath.Join(koDataPath, filename))
}

View File

@ -0,0 +1 @@
garbage contents

View File

@ -0,0 +1 @@
ref: refs/heads/branch-name

View File

@ -0,0 +1 @@
a2d1bdfe929516d7da141aef68631a7ee6941b2d