]> git.corax.cc Git - foundry/commitdiff
include/msg/dist: Add information about sources to dist message
authorMatthias Kruk <m@m10k.eu>
Sat, 27 Nov 2021 16:38:39 +0000 (01:38 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 27 Nov 2021 16:38:39 +0000 (01:38 +0900)
Dist messages do not carry any information about the sources used
to build the artifacts, making it needlessly complicated to trace
the build/distribution.
This commit adds fields for the repository, branch, and commit that
the artifacts were built from. Further, this commit renames the
field for the package repository to "distribution" so it won't be
confused with the source repository.

include/msg/dist.sh
spec/dist.json

index 535291672a3abecc8368ec190e79d189eeedeb22..5f881b38679bac25e14db71c4b42c70b03b7bd04 100644 (file)
@@ -13,7 +13,10 @@ __init() {
 foundry_msg_dist_new() {
        local context="$1"
        local repository="$2"
-       local artifacts=("${@:3}")
+       local branch="$3"
+       local ref="$4"
+       local distribution="$5"
+       local artifacts=("${@:6}")
 
        local artifacts_json
        local json
@@ -23,9 +26,12 @@ foundry_msg_dist_new() {
                return 1
        fi
 
-        if ! json=$(json_object "context"    "$context"       \
-                               "repository" "$repository"    \
-                               "artifacts"  "$artifacts_json"); then
+       if ! json=$(json_object "context"      "$context"      \
+                               "repository"   "$repository"   \
+                               "branch"       "$branch"       \
+                               "ref"          "$ref"          \
+                               "distribution" "$distribution" \
+                               "artifacts"    "$artifacts_json"); then
                return 1
        fi
 
@@ -63,6 +69,45 @@ foundry_msg_dist_get_repository() {
        return 0
 }
 
+foundry_msg_dist_get_branch() {
+       local msg="$1"
+
+       local branch
+
+       if ! branch=$(foundry_msg_get_data_field "$msg" "branch"); then
+               return 1
+       fi
+
+       echo "$branch"
+       return 0
+}
+
+foundry_msg_dist_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_dist_get_distribution() {
+       local msg="$1"
+
+       local distribution
+
+       if ! distribution=$(foundry_msg_get_data_field "$msg" "distribution"); then
+               return 1
+       fi
+
+       echo "$distribution"
+       return 0
+}
+
 foundry_msg_dist_get_artifacts() {
        local msg="$1"
 
index 014334de00bae6fd1d57807a6f7cd7883c60b5b4..41ea7913486d9b6916921b18493e01d67cd3c416 100644 (file)
            "type": "string"
        },
 
+       "repository": {
+            "description": "The URL of the repository that the artifacts were built from",
+            "type": "string",
+            "pattern": "^(https|file)://.*$"
+        },
+
+        "branch": {
+            "description": "The name of the branch the artifacts were built from",
+            "type": "string"
+        },
+
+        "ref": {
+            "description": "Identifier of the source code version",
+            "type": "string",
+            "pattern": "^[0-9a-fA-F]+$"
+        },
+
        "artifacts": {
            "description": "Artifacts that were published",
            "type": "array",
@@ -19,7 +36,7 @@
            "minItems": 1
        },
 
-       "repository": {
+       "distribution": {
            "description": "The repository where the artifacts were published",
            "type": "string"
        }
 
     "required": [
        "context",
+       "repository",
+       "branch",
+       "ref",
        "artifacts",
-       "repository"
+       "distribution"
     ],
 
     "$defs": {