Questions tagged [go-git]

Highly extensible implementation of Git protocol and storage format in Golang

go-git is is highly extensible implementation of Git protocol and storage format in Go.

It aims to reach the completeness of libgit2 or jgit, and nowadays covers the majority of the plumbing read operations and some of the main write ones, but lacks the main porcelain operations such as merges.

In its design, it has been following the open/close principle to facilitate extensions, mainly focusing the efforts on the persistence of the objects.

57 questions
1
vote
1 answer

Read a file after cloning a repository with go-git

I want to be able to do run-time git manipulations with go. I recently discovered the go-git package which comes in very handy to this end. I was also able to perform pull operations, more or less as follows: import { git…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
1
vote
1 answer

go-git: Is it possible to perform a hard reset to origin branch?

I'm trying to achieve the result of the following git commands programmatically using go-git: git fetch git reset --hard origin/ So there's git.Worktree.Reset(), which gets git.ResetOptions, which has a Commit property which is of type…
Kludge
  • 2,653
  • 4
  • 20
  • 42
1
vote
1 answer

Get Tags of specific Branch

Using go-git : is there a way to get only (lightweight and annotated) tags of a specific branch ? As I’m mainly interested in the tags of the master branch, something like git tag --merged would be sufficient too. It doesn’t seem to be possible…
1
vote
1 answer

How to use go-git to find sha of origin/master?

I am trying to use go-git to find the SHA1 of origin/master, after I have already done the equivalent of git fetch --all. However, go-git does not appear to support either: git ls-remote git@github.com:StevenACoffman/toolbox.git git rev-parse…
SteveCoffman
  • 983
  • 1
  • 8
  • 22
1
vote
1 answer

How to poll GitHub repo to pull on changes

I need to add this functionality into my GO program, with goal to poll the repo and perform a git pull on changes. I have been using https://github.com/src-d/go-git but am unable to find a way to poll. I don't want to use a webhook to avoid creating…
ecl0
  • 385
  • 1
  • 3
  • 13
0
votes
0 answers

Clone partial git repo with go-git

My golang application needs to list all file and folder paths in a subfolder of a git repo (a search path). I only care about the HEAD commit. I'm using the go-git library to clone the repo and iterate over the objects in the HEAD tree, listing…
BeetleJuice
  • 39,516
  • 19
  • 105
  • 165
0
votes
1 answer

In Go Git, how to authenticate using the SSH agent?

I've set up Git with SSH following https://docs.github.com/en/authentication/connecting-to-github-with-ssh; specifically, I've added my key to the SSH agent following…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
0
votes
1 answer

Argocd ApplicationSet, Git Generator error during fetching repo

Tested a official test code in a Argo CD reference. https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Generators-Git/ apiVersion: argoproj.io/v1alpha1 kind: ApplicationSet metadata: name: cluster-addons namespace:…
임진욱
  • 31
  • 3
0
votes
0 answers

Get Git repo folder into fs.FS

Looking for hints about how to direct my research. I have a Go application that takes a directory in the form of the io package's fs.FS as its input. However the directory it needs is actually stored in a remote git repo (Github or Gitlab). I'm…
BeetleJuice
  • 39,516
  • 19
  • 105
  • 165
0
votes
0 answers

I am facing this issue while using the go-get package, dk how to fix it

The error message : cannot use (func(c *object.Commit) error literal) (value of type func(c *"github.com/go-git/go-git/plumbing/object".Commit) error) as func(*"github.com/go-git/go-git/v5/plumbing/object".Commit) error value in argument to…
0
votes
0 answers

Validation of gpg git commit signature

I’m trying to verify git commits using go-git and I need to provide the public key (armored key ring) as a parameter to the verification function. How can I get the public key? I’m getting the signature itself from the repo. Is the key saved…
0
votes
1 answer

go-git: Create short hash (a83ad00 instead of a83ad004b3c5...)

I am using go-git and I would like to print the short hash. I mean, for example "a83ad00" instead of "a83ad004b3c5971a194ba86b96fe313b94bbcde7". I looked at the source code of got-git, but could not find a corresponding function. How to get the…
guettli
  • 25,042
  • 81
  • 346
  • 663
0
votes
1 answer

golang git - Is there a way to pull latest from remote branch if the repo is already cloned rather than cloning it again

I have a repo which needs to be cloned daily for some data. Is there a way in golang using go-git library to clone the repo only once and update the repo using git pull?
Pradeep
  • 1,198
  • 3
  • 12
  • 22
0
votes
1 answer

Go Git - Recurse Submodules

I have a project which contains submodules as shown here. [submodule "repo-a"] path = repo-a url = https://example.com/scm/repo-a.git [submodule "repo-b"] path = repo-b url = https://example.com/scm/repo-b.git [submodule "repo-c"] …
RamPrakash
  • 2,218
  • 3
  • 25
  • 54
0
votes
0 answers

Golang - get list of git remote branches without cloning the repo

I want a list of all the remote branches for a git repo. Now, this git repo can be private / public. I have the access to the token to access the repo. I am using this particular SDK : https://pkg.go.dev/github.com/go-git/go-git/v5 One way to do…
Keval Bhogayata
  • 4,422
  • 3
  • 13
  • 36