]> git.corax.cc Git - foundry/commitdiff
include/msg/build: Add ref field
authorMatthias Kruk <m@m10k.eu>
Fri, 26 Nov 2021 11:36:21 +0000 (20:36 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 26 Nov 2021 11:36:21 +0000 (20:36 +0900)
Build messages don't carry a field that identifies the version of the
built software at the source-code level.
This commit adds the "ref" field to the build message specification and
implementation.

include/msg/build.sh
spec/build.json

index 1ca0e2de9405a6934d1c94e05a7a511d50c64f10..fc08082d1442db4646634cc91bcedfc6d75f3c8f 100644 (file)
@@ -14,8 +14,9 @@ foundry_msg_build_new() {
        local context="$1"
        local repository="$2"
        local branch="$3"
-       local result="$4"
-       local -n __foundry_msg_build_new_artifacts="$5"
+       local ref="$4"
+       local result="$5"
+       local -n __foundry_msg_build_new_artifacts="$6"
 
        local artifact_array
        local json
@@ -28,6 +29,7 @@ foundry_msg_build_new() {
        if ! json=$(json_object "context"    "$context"       \
                                "repository" "$repository"    \
                                "branch"     "$branch"        \
+                               "ref"        "$ref"           \
                                "result"     "$result"        \
                                "artifacts"  "$artifact_array"); then
                return 1
@@ -80,6 +82,19 @@ foundry_msg_build_get_branch() {
        return 0
 }
 
+foundry_msg_build_get_ref() {
+       local msg="$1"
+
+       local ref
+
+       if ! ref=$(foundry_msg_get_data_field "$msg" "ref"); then
+               return 1
+       fi
+
+       echo "$ref"
+       return 0
+}
+
 foundry_msg_build_get_result() {
        local msg="$1"
 
index 2a1ea3293e1134f7afe1085fcf0012412dbe2ff2..ef6c9e639a321775709df58dda4b92eaf01c98ac 100644 (file)
            "type": "string"
        },
 
+       "ref": {
+           "description": "Identifier of the source code version",
+           "type": "string",
+           "pattern": "^[0-9a-fA-F]+$"
+       },
+
        "artifacts": {
            "description": "The files resulting from the build",
            "type": "array",
@@ -35,6 +41,7 @@
        "context",
        "repository",
        "branch",
+       "ref",
        "artifacts"
     ],