#Is it possible to checkout the source for a specific SHA?

1 messages · Page 1 of 1 (latest)

tiny sorrel
#

Currently, when I need to checkout the source, I do this.

// clone repository with Dagger
repo := client.Git(repoUrl)
src, err := repo.Branch("master").Tree().ID(ctx)
if err != nil {
    return err
}

And it seems that there is no such method as SHA(string) in the repo.

Is there any way that I can checkout from a specific SHA?

vital wraith
#

Hi @tiny sorrel , yes that is possible, I believe there is an optional "ref" option to Git

#

Oh nevermind. Perhaps it is encoded in the url now? cc @opal palm

#

I guess what you are looking for is something like:

client.Git(repoUrl).Commit(repoSha).Tree()
runic crest
#

As a workaround -- You can actually pass the commit inside Branch

#

client.Git(repoURL).Branch(commit).Tree()

tiny sorrel
#

Ah I see. Thank you so much for the prompt answer! And one minor suggestion - could you document this behavior (workaround) in the SDK doc?

young lily
tiny sorrel
#

🙏

runic crest
scarlet bridge
vital wraith
#

@scarlet bridge that's been suggested before, I also added a short explanation as to why I prefer specific terms rather than "ref"

scarlet bridge
#

Makes sense!

vital wraith
#

Making a PR now 🙂