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
2
votes
2 answers

How to find common ancestor for two branches programmatically

I am working on a project where I integrated my project with git. For integration purpose, I am using go-git library. My question is how can I find a common ancestor for two branches programmatically? I want to implement this function. Looks like…
Abhishek Soni
  • 289
  • 2
  • 4
  • 15
1
vote
1 answer

what is the difference between git and go-git

My application use go-git library and I recently became aware of CVE-2022-23521 , CVE-2022-41903 issues about git. I want to know if these issues affect go-git (https://github.com/go-git/go-git). This is description of go-git. go-git is a highly…
alexmoon
  • 356
  • 1
  • 3
  • 10
1
vote
0 answers

How do I do the equivalent of `git remote set-branches origin --add other-branch` in go-git?

I have a huge repository with extensive commit history. To reduce clone time, I do a single branch option with a depth of 1. This immensely speeds up my cloning time however, it cannot properly resolve remote branches like this. Wondering if I can…
Sathish
  • 409
  • 8
  • 24
1
vote
0 answers

How to use PathFilter correctly in go-git?

I am trying to analyze the git commit log by using go-git. But I encountered some problems and failed to solve them after many attempts. In WSL(Ubuntu18.04), the command root@(XXXXXXX/XXXXXX):.../www/docs/docs/gmaster# git log intro.mdx will return…
mmmhongyu
  • 11
  • 1
1
vote
1 answer

How to checkout a specific single file to inspect it using go-git?

I want to clone a specific repository, fetch all tags and iterate through them. For each tag I want to checkout a specific file ( package.json ) in the root directory. If no file is present, it should continue, otherwise it should pass it over so I…
baitendbidz
  • 187
  • 3
  • 19
1
vote
1 answer

`git log -G ...` with golang

I want to write a script which is similar to git log -G with go-git This code prints all commits of the repos, but how to get the added/removed lines of each commit? package main import ( "fmt" "os" "path/filepath" …
guettli
  • 25,042
  • 81
  • 346
  • 663
1
vote
0 answers

go-git timing out creating tree

I'm doing a similar implementation of this example https://github.com/google/go-github/blob/03b5525554d33bcc1a735ab509224599107227a9/example/commitpr/main.go I'm running into this error POST https://api.github.com/repos/XXX/XXX/git/trees: 502 Sorry,…
Rafael Simões
  • 347
  • 1
  • 4
  • 12
1
vote
0 answers

"failed to load compute presentation" error while using git.NewRemote for listing tag in golang

i am trying to fetch all the tags of a gitlab repo without cloning the code via go-git package. As per go documentation (https://github.com/go-git/go-git/blob/v5.4.2/_examples/ls-remote/main.go) i am using git.newRemote to create a new remote for…
1
vote
1 answer

go-git "git submodule add "

TLDR I've been scouring the package Docs & the official Examples and can't figure out how to describe adding a submodule using go-git. I'm trying to git submodule add , as well as configure it for sparse checkout Goal I want to…
aRustyDev
  • 101
  • 1
  • 11
1
vote
0 answers

Go-Git custom push options

I want to push to gitlab from a go program. I'm using go-git v5 for it. The standard push is working fine: err := repo.Push(&git.PushOptions{ RefSpecs: []config.RefSpec{"refs/tags/*:refs/tags/*"}, Progress: os.Stdout, …
gausss
  • 343
  • 2
  • 4
  • 16
1
vote
2 answers

How to unit test with go-git

How do I write a unit test for my code that clones a repo using git-go Below is a sample of the function I have created. I am cloning multiple repos and reading a particular file that is in that repo, I am unsure how to unit test this function. func…
Danial Ang
  • 107
  • 1
  • 7
1
vote
1 answer

How to get the git tags for a particular hash in go using go-git package to get an output similar to git describe --tags --always

I am using the go-git package to get the tags, on using the function "TagObject", it is returning null. How should I write it? Actual file: hashCommit, _ := r.Head() tagObj, _ := r.TagObject(hashCommit.Hash()) Test file: tags, err :=…
1
vote
1 answer

go-git how to generate patch for first commit?

I have following code commitIter, err := r.Log(&git.LogOptions{From: commit.Hash}) CheckIfError(err) err = commitIter.ForEach(func(c *object.Commit) error { parent, err := c.Parent(0) if err != nil { return…
kernelc
  • 98
  • 7
1
vote
1 answer

git credential.helper instead of .netrc to get go dependencies

To cashing go dependencies I use nexus(as goproxy) which connect to goproxy servers (because nexus can't get dependencies directly from GitHub) outside of private network. nexus.some.repo.com:4443/repository/go-nexus-proxy ➡️…
kozmo
  • 4,024
  • 3
  • 30
  • 48
1
vote
1 answer

Why are my commits via go-git dated 1970?

I am committing changes via go-git: import ( "github.com/tcnksm/go-gitconfig" "github.com/walterjwhite/go-application/libraries/logging" "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing/object" ) func stackoverflowCommit(R…
Walter
  • 1,290
  • 2
  • 21
  • 46