aboutsummaryrefslogtreecommitdiffstats
path: root/_examples/ls-remote
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-05-03 10:46:39 +0100
committerGitHub <noreply@github.com>2023-05-03 10:46:39 +0100
commit02856b824a05c18118c116af5b0e2bca1b3496b3 (patch)
tree86f0f043a8176a790c132d2862f8f3f4565c398e /_examples/ls-remote
parent0542a302c2be7ed7de276411f7e20b87309734b9 (diff)
parent19b39e150071832541f2cdcb669446a8609f57e7 (diff)
downloadgo-git-02856b824a05c18118c116af5b0e2bca1b3496b3.tar.gz
Merge pull request #750 from pjbgf/peel
git: Add support to ls-remote with peeled references. Fixes #749
Diffstat (limited to '_examples/ls-remote')
-rw-r--r--_examples/ls-remote/main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/_examples/ls-remote/main.go b/_examples/ls-remote/main.go
index af038d6..e49e8c9 100644
--- a/_examples/ls-remote/main.go
+++ b/_examples/ls-remote/main.go
@@ -2,25 +2,35 @@ package main
import (
"log"
+ "os"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/storage/memory"
+
+ . "github.com/go-git/go-git/v5/_examples"
)
// Retrieve remote tags without cloning repository
func main() {
+ CheckArgs("<url>")
+ url := os.Args[1]
+
+ Info("git ls-remote --tags %s", url)
// Create the remote with repository URL
rem := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{
Name: "origin",
- URLs: []string{"https://github.com/Zenika/MARCEL"},
+ URLs: []string{url},
})
log.Print("Fetching tags...")
// We can then use every Remote functions to retrieve wanted information
- refs, err := rem.List(&git.ListOptions{})
+ refs, err := rem.List(&git.ListOptions{
+ // Returns all references, including peeled references.
+ PeelingOption: git.AppendPeeled,
+ })
if err != nil {
log.Fatal(err)
}