Skip to content

source: add raw commit/tag object access to resolveMetadata - #6298

Merged
tonistiigi merged 3 commits into
moby:masterfrom
tonistiigi:git-object-resolve
Oct 22, 2025
Merged

tonistiigi merged 3 commits into
moby:masterfrom
tonistiigi:git-object-resolve

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

depends on #6293

When calling ResolveSourceMetadata on Git source, if ReturnObject is set then raw commit and tag objects are returned with the response for more detailed inspection.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi
tonistiigi marked this pull request as ready for review October 18, 2025 19:37
Message string
}

func Parse(raw []byte) (*GitObject, error) {

@crazy-max crazy-max Oct 20, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we could use https://github.com/go-git/go-git to parse objects?

@crazy-max crazy-max Oct 20, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we could just use the plumbing package if it's not too heavy: https://github.com/go-git/go-git/blob/0fe67ec8dc1d6474b430fefe415737dbe8211f89/plumbing/object.go#L42-L47

import (
	"github.com/go-git/go-git/v5/plumbing"
	"github.com/go-git/go-git/v5/plumbing/object"
)

...

	obj := &plumbing.MemoryObject{}
	obj.SetType(plumbing.CommitObject)
	obj.SetSize(int64(len(raw)))

	w, _ := obj.Writer()
	w.Write(raw)
	w.Close()

	commit, err := object.DecodeCommit(obj)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is too heavy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed it imports a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants