fork of go-git with some jj specific features

_examples: Add sparse checkout example.

authored by onee-only and committed by Paulo Gomes 29bc1530 b422784f

Changed files
+33
_examples
sparse-checkout
+1
COMPATIBILITY.md
··· 34 | `merge` | | ⚠️ (partial) | Fast-forward only | | 35 | `mergetool` | | ❌ | | | 36 | `stash` | | ❌ | | | 37 | `tag` | | ✅ | | - [tag](_examples/tag/main.go) <br/> - [tag create and push](_examples/tag-create-push/main.go) | 38 39 ## Sharing and updating projects
··· 34 | `merge` | | ⚠️ (partial) | Fast-forward only | | 35 | `mergetool` | | ❌ | | | 36 | `stash` | | ❌ | | | 37 + | `sparse-checkout` | | ✅ | | - [sparse-checkout](_examples/sparse-checkout/main.go) | 38 | `tag` | | ✅ | | - [tag](_examples/tag/main.go) <br/> - [tag create and push](_examples/tag-create-push/main.go) | 39 40 ## Sharing and updating projects
+1
_examples/common_test.go
··· 33 "revision": {cloneRepository(defaultURL, tempFolder()), "master~2^"}, 34 "sha256": {tempFolder()}, 35 "showcase": {defaultURL, tempFolder()}, 36 "tag": {cloneRepository(defaultURL, tempFolder())}, 37 } 38
··· 33 "revision": {cloneRepository(defaultURL, tempFolder()), "master~2^"}, 34 "sha256": {tempFolder()}, 35 "showcase": {defaultURL, tempFolder()}, 36 + "sparse-checkout": {defaultURL, "vendor", tempFolder()}, 37 "tag": {cloneRepository(defaultURL, tempFolder())}, 38 } 39
+31
_examples/sparse-checkout/main.go
···
··· 1 + package main 2 + 3 + import ( 4 + "os" 5 + 6 + "github.com/go-git/go-git/v5" 7 + . "github.com/go-git/go-git/v5/_examples" 8 + ) 9 + 10 + func main() { 11 + CheckArgs("<url>", "<sparse_path>", "<directory>") 12 + url := os.Args[1] 13 + path := os.Args[2] 14 + directory := os.Args[3] 15 + 16 + Info("git clone %s %s", url, directory) 17 + 18 + r, err := git.PlainClone(directory, false, &git.CloneOptions{ 19 + URL: url, 20 + NoCheckout: true, 21 + }) 22 + CheckIfError(err) 23 + 24 + w, err := r.Worktree() 25 + CheckIfError(err) 26 + 27 + err = w.Checkout(&git.CheckoutOptions{ 28 + SparseCheckoutDirectories: []string{path}, 29 + }) 30 + CheckIfError(err) 31 + }