Giter Club home page Giter Club logo

Comments (10)

GridexX avatar GridexX commented on May 18, 2024 4

We really need this feature, is there a roadmap or something we can do for helping you ?
We could pay in ETHW 😄

from go-git.

github-actions avatar github-actions commented on May 18, 2024 4

To help us keep things tidy and focus on the active tasks, we've introduced a stale bot to spot issues/PRs that haven't had any activity in a while.

This particular issue hasn't had any updates or activity in the past 90 days, so it's been labeled as 'stale'. If it remains inactive for the next 30 days, it'll be automatically closed.

We understand everyone's busy, but if this issue is still important to you, please feel free to add a comment or make an update to keep it active.

Thanks for your understanding and cooperation!

from go-git.

antonosmond avatar antonosmond commented on May 18, 2024 1

@yordis AFAICT, sparse checkout is supported. You can see it in this test:

go-git/repository_test.go

Lines 291 to 320 in 809f9df

func (s *RepositorySuite) TestCloneSparse(c *C) {
fs := memfs.New()
r, err := Clone(memory.NewStorage(), fs, &CloneOptions{
URL: s.GetBasicLocalRepositoryURL(),
})
c.Assert(err, IsNil)
w, err := r.Worktree()
c.Assert(err, IsNil)
sparseCheckoutDirectories := []string{"go", "json", "php"}
c.Assert(w.Checkout(&CheckoutOptions{
Branch: "refs/heads/master",
SparseCheckoutDirectories: sparseCheckoutDirectories,
}), IsNil)
fis, err := fs.ReadDir(".")
c.Assert(err, IsNil)
for _, fi := range fis {
c.Assert(fi.IsDir(), Equals, true)
var oneOfSparseCheckoutDirs bool
for _, sparseCheckoutDirectory := range sparseCheckoutDirectories {
if strings.HasPrefix(fi.Name(), sparseCheckoutDirectory) {
oneOfSparseCheckoutDirs = true
}
}
c.Assert(oneOfSparseCheckoutDirs, Equals, true)
}
}

That being said, I'm trying to use this and it doesn't appear to working. After the checkout, I seem to have all dirs in the worktree, not just the sparse dirs. If you get it working, let me know! Thanks!

from go-git.

c4milo avatar c4milo commented on May 18, 2024

this will be a great addition 🙌

from go-git.

yordis avatar yordis commented on May 18, 2024

Hey folks, I am trying to contribute to ArgoCD (and potentially FluxCD) by adding sparse checkout: argoproj/argo-cd#14272

But it seems it is not supported. Any opportunity to make the issue a priority?

from go-git.

yordis avatar yordis commented on May 18, 2024

I removed the usage of the package btw!

from go-git.

emirot avatar emirot commented on May 18, 2024

@yordis @antonosmond

What did not work?

It looks to be working in my simple test: https://github.com/emirot/test-go-git/tree/main

from go-git.

jberger-dynatrace avatar jberger-dynatrace commented on May 18, 2024

We would appreciate this feature as well!

from go-git.

object88 avatar object88 commented on May 18, 2024

I also am having trouble using SparseCheckoutDirectories (with go-git v5.11.0). My case may be slightly strange, though. I want to get a sparse checkout from a particular commit. My code, in brief:

        # sha -> 40 character SHA
        # path -> subfolder in my repo, ala "src/app/config"
        # repo -> git form of my repo, ala "[email protected]:myorg/myrepo.git"

	tempDir, _ := os.MkdirTemp("", "source-*")
	fs := osfs.New(tempDir)
	dot, _ := fs.Chroot(".git")
	s := filesystem.NewStorage(dot, cache.NewObjectLRUDefault())

	refspec := config.RefSpec(fmt.Sprintf("+%s:refs/remotes/origin/%s", sha, sha))
	r, _ := gogit.Init(s, fs)
	r.CreateRemote(&config.RemoteConfig{
		Fetch: []config.RefSpec{refspec},
		Name:  "origin",
		URLs:  []string{repo},
	})
	w, _ := r.Worktree()

	r.Fetch(&gogit.FetchOptions{
		Depth:           1,
		InsecureSkipTLS: false,
		Tags:            gogit.NoTags,
	})

	w.Checkout(&gogit.CheckoutOptions{
		Hash:                      plumbing.NewHash(sha),
		SparseCheckoutDirectories: []string{path},
	})

While the sample code above does not show error checking, it is present in my actual code, and no errors are coming back.

I have also tried setting path as just "src" (instead of "src/app/cfg") to match the test mentioned above, but same behavior. Also same if I add a Force: true to the CheckoutOptions.

from go-git.

wilstdu avatar wilstdu commented on May 18, 2024

@yordis @antonosmond

What did not work?

It looks to be working in my simple test: https://github.com/emirot/test-go-git/tree/main

@emirot for you this works, because your example doesn't have NoCheckout: true, in git.CloneOptions of git.PlainClone

from go-git.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.