MCPcopy Create free account
hub / github.com/belak/gitdir / Checkout

Method Checkout

internal/git/repository.go:112–130  ·  view source on GitHub ↗

Checkout will checkout the given hash to the worktreeFS. If an empty string is given, we checkout master.

(hash string)

Source from the content-addressed store, hash-verified

110// Checkout will checkout the given hash to the worktreeFS. If an empty string
111// is given, we checkout master.
112func (r *Repository) Checkout(hash string) error {
113 opts := &git.CheckoutOptions{
114 Force: true,
115 }
116
117 if hash != "" {
118 opts.Hash = plumbing.NewHash(hash)
119 }
120
121 err := r.Worktree.Checkout(opts)
122
123 // It's fine to ignore ErrReferenceNotFound because that means this is a
124 // repo without any commits which doesn't matter for our use cases.
125 if err != nil && !errors.Is(err, plumbing.ErrReferenceNotFound) {
126 return err
127 }
128
129 return nil
130}
131
132func ensureHooks(fs billy.Filesystem) error {
133 exe, err := os.Executable()

Callers 6

loadOrgConfigMethod · 0.80
openAdminRepoMethod · 0.80
SetHashMethod · 0.80
SetUserHashMethod · 0.80
SetOrgHashMethod · 0.80
loadUserConfigMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected