From 411b3667ef4f4dd40630032ba5a034ba2e52ee29 Mon Sep 17 00:00:00 2001 From: Matej Risek Date: Mon, 25 Mar 2024 11:38:55 +0100 Subject: [PATCH] WIP --- sourcebundle/builder.go | 9 +++++++-- sourcebundle/bundle.go | 5 ++++- sourcebundle/manifest_json.go | 3 ++- sourcebundle/package_meta.go | 19 ++++++++++--------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sourcebundle/builder.go b/sourcebundle/builder.go index 1001de7..217065a 100644 --- a/sourcebundle/builder.go +++ b/sourcebundle/builder.go @@ -560,8 +560,13 @@ func (b *Builder) writeManifest(filename string) error { SourceAddr: pkgAddr.String(), LocalDir: localDirName, } - if pkgMeta != nil && pkgMeta.gitCommitID != "" { - manifestPkg.Meta.GitCommitID = pkgMeta.gitCommitID + if pkgMeta != nil { + if pkgMeta.GitCommitID != "" { + manifestPkg.Meta.GitCommitID = pkgMeta.GitCommitID + } + if pkgMeta.GitCommitMessage != "" { + manifestPkg.Meta.GitCommitMessage = pkgMeta.GitCommitMessage + } } root.Packages = append(root.Packages, manifestPkg) diff --git a/sourcebundle/bundle.go b/sourcebundle/bundle.go index a239a1d..6ce8d58 100644 --- a/sourcebundle/bundle.go +++ b/sourcebundle/bundle.go @@ -91,7 +91,10 @@ func OpenDir(baseDir string) (*Bundle, error) { ret.remotePackageDirs[pkgAddr] = localDir if rpm.Meta.GitCommitID != "" { - ret.remotePackageMeta[pkgAddr] = PackageMetaWithGitCommit(rpm.Meta.GitCommitID) + ret.remotePackageMeta[pkgAddr] = &PackageMeta{ + GitCommitID: rpm.Meta.GitCommitID, + GitCommitMessage: rpm.Meta.GitCommitMessage, + } } } diff --git a/sourcebundle/manifest_json.go b/sourcebundle/manifest_json.go index 79f5386..b371e6d 100644 --- a/sourcebundle/manifest_json.go +++ b/sourcebundle/manifest_json.go @@ -47,5 +47,6 @@ type manifestRegistryVersion struct { } type manifestPackageMeta struct { - GitCommitID string `json:"git_commit_id,omitempty"` + GitCommitID string `json:"git_commit_id,omitempty"` + GitCommitMessage string `json:"git_commit_message,omitempty"` } diff --git a/sourcebundle/package_meta.go b/sourcebundle/package_meta.go index 9380f17..fe01681 100644 --- a/sourcebundle/package_meta.go +++ b/sourcebundle/package_meta.go @@ -16,18 +16,19 @@ type PackageMeta struct { // this struct ends up getting too big and is only sparsely used by most // fetchers. - gitCommitID string + GitCommitID string + GitCommitMessage string } // PackageMetaWithGitCommit returns a [PackageMeta] object with a Git Commit // ID tracked. The given commit ID must be a fully-qualified ID, and never an // abbreviated commit ID, the name of a ref, or anything other proxy-for-commit // identifier. -func PackageMetaWithGitCommit(commitID string) *PackageMeta { - return &PackageMeta{ - gitCommitID: commitID, - } -} +//func PackageMetaWithGitCommit(commitID string) *PackageMeta { +// return &PackageMeta{ +// gitCommitID: commitID, +// } +//} // If the content of this package was derived from a particular commit // from a Git repository, GitCommitID returns the fully-qualified ID of @@ -35,6 +36,6 @@ func PackageMetaWithGitCommit(commitID string) *PackageMeta { // or anything else that could serve as a proxy for a commit ID. // // If there is no relevant commit ID for this package, returns an empty string. -func (m *PackageMeta) GitCommitID() string { - return m.gitCommitID -} +//func (m *PackageMeta) GitCommitID() string { +// return m.gitCommitID +//}