Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
matejrisek committed Mar 25, 2024
1 parent 0ba92f7 commit 411b366
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
9 changes: 7 additions & 2 deletions sourcebundle/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion sourcebundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion sourcebundle/manifest_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
19 changes: 10 additions & 9 deletions sourcebundle/package_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ 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
// that commit. This is never an abbreviated commit ID, the name of a ref,
// 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
//}

0 comments on commit 411b366

Please sign in to comment.