mirror of
https://github.com/kennyp/asdf-golang.git
synced 2024-10-06 04:32:07 +08:00
Extract version from go.mod files (#32)
* Extract version from go.mod files * make it work on linux too * whitespace * ignore asdf testing checkout * fix test
This commit is contained in:
parent
831b8db058
commit
b7780500cf
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/asdf/
|
@ -1,5 +1,5 @@
|
||||
language: c
|
||||
script: asdf plugin test golang . --asdf-plugin-gitref $TRAVIS_COMMIT go version
|
||||
script: asdf plugin test golang $TRAVIS_BUILD_DIR --asdf-plugin-gitref $TRAVIS_COMMIT go version
|
||||
before_script:
|
||||
- if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y bsdmainutils; fi
|
||||
- git clone https://github.com/asdf-vm/asdf.git
|
||||
@ -11,6 +11,6 @@ matrix:
|
||||
- os: linux
|
||||
arch: ppc64le
|
||||
- os: linux
|
||||
arch: arm64
|
||||
arch: arm64
|
||||
- os: osx
|
||||
arch: amd64
|
||||
arch: amd64
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo ".go-version"
|
||||
echo ".go-version go.mod"
|
||||
|
21
bin/parse-legacy-file
Executable file
21
bin/parse-legacy-file
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
get_legacy_version() {
|
||||
current_file="$1"
|
||||
basename=$(basename -- "$current_file")
|
||||
|
||||
if [ "$basename" == "go.mod" ]; then
|
||||
GOLANG_VERSION=$(grep 'go\s*[0-9]' "$current_file" |
|
||||
sed -e 's/.*heroku goVersion //' \
|
||||
-e 's/[[:space:]]//' \
|
||||
-e 's/go\(.*\)/\1/' |
|
||||
head -1
|
||||
)
|
||||
else
|
||||
GOLANG_VERSION=$(cat "$current_file")
|
||||
fi
|
||||
|
||||
echo "$GOLANG_VERSION"
|
||||
}
|
||||
|
||||
get_legacy_version "$1"
|
Loading…
Reference in New Issue
Block a user