@@ -120,28 +120,31 @@ configure_git_ssl_verification() {
120120}
121121
122122add_git_metadata_basic () {
123- local commit=$( git rev-parse HEAD | jq -R .)
124- local author=$( git log -1 --format=format:%an | jq -s -R .)
125- local author_date=$( git log -1 --format=format:%ai | jq -R .)
126-
127- jq " . + [
128- {name: \" commit\" , value: ${commit} },
129- {name: \" author\" , value: ${author} },
130- {name: \" author_date\" , value: ${author_date} , type: \" time\" }
131- ]"
123+ local commit=$( git rev-parse HEAD)
124+ local author=$( git log -1 --format=format:%an)
125+ local author_date=$( git log -1 --format=format:%ai)
126+
127+ jq --arg commit " $commit " \
128+ --arg author " $author " \
129+ --arg author_date " $author_date " \
130+ ' . + [
131+ {name: "commit", value: $commit},
132+ {name: "author", value: $author},
133+ {name: "author_date", value: $author_date, type: "time"}
134+ ]'
132135}
133136
134137add_git_metadata_committer () {
135- local author=$( git log -1 --format=format:%an | jq -s -R . )
136- local author_date=$( git log -1 --format=format:%ai | jq -R . )
137- local committer=$( git log -1 --format=format:%cn | jq -s -R . )
138- local committer_date=$( git log -1 --format=format:%ci | jq -R . )
138+ local author=$( git log -1 --format=format:%an)
139+ local author_date=$( git log -1 --format=format:%ai)
140+ local committer=$( git log -1 --format=format:%cn)
141+ local committer_date=$( git log -1 --format=format:%ci)
139142
140143 if [ " $author " = " $committer " ] && [ " $author_date " = " $committer_date " ]; then
141- jq " . + [
142- {name: \ " committer\ " , value: ${ committer} },
143- {name: \ " committer_date\ " , value: ${ committer_date} , type: \ " time\ " }
144- ]"
144+ jq --arg committer " $committer " --arg committer_date " $committer_date " ' . + [
145+ {name: "committer", value: $committer},
146+ {name: "committer_date", value: $committer_date, type: "time"}
147+ ]'
145148 else
146149 cat
147150 fi
@@ -153,9 +156,9 @@ add_git_metadata_branch() {
153156 jq -R " . | select(. != \"\" )" | jq -r -s " map(.) | join (\" ,\" )" )
154157
155158 if [ -n " ${branch} " ]; then
156- jq " . + [
157- {name: \ " branch\ " , value: \" ${ branch} \" }
158- ]"
159+ jq --arg branch " $branch " ' . + [
160+ {name: "branch", value: $ branch}
161+ ]'
159162 else
160163 cat
161164 fi
@@ -167,20 +170,32 @@ add_git_metadata_tags() {
167170 jq -r -s " map(.) | join(\" ,\" )" )
168171
169172 if [ -n " ${tags} " ]; then
170- jq " . + [
171- {name: \" tags\" , value: \" ${tags} \" }
172- ]"
173+ jq --arg tags " $tags " ' . + [
174+ {name: "tags", value: $tags}
175+ ]'
176+ else
177+ cat
178+ fi
179+ }
180+
181+ add_git_metadata_tag () {
182+ local tag=$( git tag --points-at HEAD)
183+
184+ if [ -n " ${tag} " ]; then
185+ jq --arg tag " $tag " ' . + [
186+ {name: "tag", value: $tag}
187+ ]'
173188 else
174189 cat
175190 fi
176191}
177192
178193add_git_metadata_message () {
179- local message=$( git log -1 --format=format:%B | head -c 10240 | jq -s -R . )
194+ local message=$( git log -1 --format=format:%B | head -c 10240)
180195
181- jq " . + [
182- {name: \ " message\ " , value: ${ message} , type: \ " message\ " }
183- ]"
196+ jq --arg message " $message " ' . + [
197+ {name: "message", value: $message, type: "message"}
198+ ]'
184199}
185200
186201add_git_metadata_url () {
@@ -213,9 +228,9 @@ add_git_metadata_url() {
213228 esac
214229
215230 if [ -n " $url " ]; then
216- jq " . + [
217- {name: \ " url\ " , value: \" ${ url} \" }
218- ]"
231+ jq --arg url " $url " ' . + [
232+ {name: "url", value: $ url}
233+ ]'
219234 else
220235 jq " . + []"
221236 fi
@@ -232,6 +247,15 @@ git_metadata() {
232247 add_git_metadata_url
233248}
234249
250+ git_tag_metadata () {
251+ jq -n " []" | \
252+ add_git_metadata_basic | \
253+ add_git_metadata_committer | \
254+ add_git_metadata_tag | \
255+ add_git_metadata_message | \
256+ add_git_metadata_url
257+ }
258+
235259configure_submodule_credentials () {
236260 local username
237261 local password
0 commit comments