Skip to content

Commit b70f6c9

Browse files
committed
Add logic to update INFO files.
1 parent fe6885c commit b70f6c9

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

update_sources.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
set -o errexit -o errtrace -o nounset -o pipefail
44

5-
update_sources() {
5+
: "${GIT:=git}"
66

7-
get_project_name_from_github_url() {
8-
local sContent sProject sUrl
7+
update_sources() {
98

10-
readonly sContent="${1?One parameter required: <content>}"
9+
local -r sScriptPath="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
1110

12-
readonly sUrl=$(echo "${sContent}" | grep -E '^SOURCE=' | grep -oE 'https?://.*')
13-
readonly sProject="$(echo "${sUrl}" | rev | grep -oE '[^/]+/[^/]+' | rev)"
14-
15-
echo "${sProject}"
16-
}
11+
# shellcheck source=./src/function.get_local_version.sh
12+
source "${sScriptPath}/src/function.get_local_version.sh"
13+
# shellcheck source=./src/function.get_project_name_from_github_url.sh
14+
source "${sScriptPath}/src/function.get_project_name_from_github_url.sh"
15+
# shellcheck source=./src/function.get_version_from_remote_git.sh
16+
source "${sScriptPath}/src/function.get_version_from_remote_git.sh"
1717

1818
update_source() {
19-
local iLength sConfig sFilePath sPath sProject sSource sSourceFile sSourcePath sTargetFile sTargetPath
19+
local iLength sConfig sFilePath sPath sProject sRemoteVersion sSource sSourceFile sSourcePath sTargetFile sTargetFolder sTargetPath
2020

2121
readonly sProject="${1?Five parameters required: <project> <target-path> <source-path> <path> <config>}"
2222
readonly sTargetPath="${2?Five parameters required: <project> <target-path> <source-path> <path> <config>}"
@@ -62,6 +62,22 @@ update_sources() {
6262
echo -e "\tNo '*.puml' files found. Skipping"
6363
# @TODO: Check if there is an SVG (or PNG?) source dir and generate '*.puml' files from there
6464
fi
65+
66+
echo " -----> Writing INFO file"
67+
sRemoteVersion="$(get_version_from_remote_git "${sProject}")"
68+
69+
if [[ "${sRemoteVersion}" == '' ]];then
70+
sRemoteVersion="0.0.1"
71+
fi
72+
73+
if echo "${sRemoteVersion}" | grep -E '^[0-9]+\.[0-9]+$';then
74+
sRemoteVersion="${sRemoteVersion}.0"
75+
fi
76+
77+
cat > "${sTargetPath}/${sPath}/INFO" <<TXT
78+
VERSION=${sRemoteVersion}
79+
SOURCE=https://github.com/${sProject}
80+
TXT
6581
fi
6682
}
6783

0 commit comments

Comments
 (0)