Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
be322fc5
Commit
be322fc5
authored
Sep 05, 2014
by
Filipe Brandenburger
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1174 from eparis/version-shell-overrides
Allow setting of git_commit, version, and dirty via shell varables
parents
d3b06363
428e0aaf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
config-go.sh
hack/config-go.sh
+16
-14
No files found.
hack/config-go.sh
View file @
be322fc5
...
@@ -34,31 +34,33 @@ kube::version_ldflags() {
...
@@ -34,31 +34,33 @@ kube::version_ldflags() {
cd
"
${
KUBE_REPO_ROOT
}
"
cd
"
${
KUBE_REPO_ROOT
}
"
declare
-a
ldflags
=()
declare
-a
ldflags
=()
if
git_commit
=
$(
git rev-parse
"HEAD^{commit}"
2>/dev/null
)
;
then
if
[[
-n
${
KUBE_GIT_COMMIT
-
}
]]
||
KUBE_GIT_COMMIT
=
$(
git rev-parse
"HEAD^{commit}"
2>/dev/null
)
;
then
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitCommit"
"
${
git_commit
}
"
)
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitCommit"
"
${
KUBE_GIT_COMMIT
}
"
)
# Check if the tree is dirty.
if
[[
-z
${
KUBE_GIT_TREE_STATE
-
}
]]
;
then
if
git_status
=
$(
git status
--porcelain
)
&&
[[
-z
"
${
git_status
}
"
]]
;
then
# Check if the tree is dirty. default to dirty
git_tree_state
=
"clean"
if
git_status
=
$(
git status
--porcelain
2>/dev/null
)
&&
[[
-z
${
git_status
}
]]
;
then
else
KUBE_GIT_TREE_STATE
=
"clean"
git_tree_state
=
"dirty"
else
KUBE_GIT_TREE_STATE
=
"dirty"
fi
fi
fi
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitTreeState"
"
${
git_tree_state
}
"
)
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitTreeState"
"
${
KUBE_GIT_TREE_STATE
}
"
)
# Use git describe to find the version based on annotated tags.
# Use git describe to find the version based on annotated tags.
if
git_version
=
$(
git describe
--abbrev
=
14
"
${
git_commit
}
^{commit}"
2>/dev/null
)
;
then
if
[[
-n
${
KUBE_GIT_VERSION
-
}
]]
||
KUBE_GIT_VERSION
=
$(
git describe
--abbrev
=
14
"
${
KUBE_GIT_COMMIT
}
^{commit}"
2>/dev/null
)
;
then
if
[[
"
${
git_tree_state
}
"
==
"dirty"
]]
;
then
if
[[
"
${
KUBE_GIT_TREE_STATE
}
"
==
"dirty"
]]
;
then
# git describe --dirty only considers changes to existing files, but
# git describe --dirty only considers changes to existing files, but
# that is problematic since new untracked .go files affect the build,
# that is problematic since new untracked .go files affect the build,
# so use our idea of "dirty" from git status instead.
# so use our idea of "dirty" from git status instead.
git_version
+
=
"-dirty"
KUBE_GIT_VERSION
+
=
"-dirty"
fi
fi
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitVersion"
"
${
git_version
}
"
)
ldflags+
=(
-X
"
${
KUBE_GO_PACKAGE
}
/pkg/version.gitVersion"
"
${
KUBE_GIT_VERSION
}
"
)
# Try to match the "git describe" output to a regex to try to extract
# Try to match the "git describe" output to a regex to try to extract
# the "major" and "minor" versions and whether this is the exact tagged
# the "major" and "minor" versions and whether this is the exact tagged
# version or whether the tree is between two tagged versions.
# version or whether the tree is between two tagged versions.
if
[[
"
${
git_version
}
"
=
~ ^v
([
0-9]+
)
\.
([
0-9]+
)([
.-].
*
)
?
$
]]
;
then
if
[[
"
${
KUBE_GIT_VERSION
}
"
=
~ ^v
([
0-9]+
)
\.
([
0-9]+
)([
.-].
*
)
?
$
]]
;
then
git_major
=
${
BASH_REMATCH
[1]
}
git_major
=
${
BASH_REMATCH
[1]
}
git_minor
=
${
BASH_REMATCH
[2]
}
git_minor
=
${
BASH_REMATCH
[2]
}
if
[[
-n
"
${
BASH_REMATCH
[3]
}
"
]]
;
then
if
[[
-n
"
${
BASH_REMATCH
[3]
}
"
]]
;
then
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment