update to libgit2 version 1.8.4. dump old github and vendor stuff
go install go.wit.com/apps/go-clone@latest go install go.wit.com/apps/go-mod-clean@latest go-clone --recusive go.wit.com/lib/git2go Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
e65b1c188c
commit
530f3618a8
|
@ -1,54 +0,0 @@
|
|||
name: Backport to older releases
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
|
||||
backport:
|
||||
name: Backport change to branch ${{ matrix.branch }}
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branch: [ 'release-1.3', 'release-1.2', 'release-1.1', 'release-1.0', 'release-0.28', 'release-0.27' ]
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Create a cherry-pick PR
|
||||
run: |
|
||||
if ! git diff --quiet HEAD^ HEAD -- vendor/libgit2; then
|
||||
echo '::warning::Skipping cherry-pick since it is a vendored libgit2 bump'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
BRANCH_NAME="cherry-pick-${{ github.run_id }}-${{ matrix.branch }}"
|
||||
|
||||
# Setup usernames and authentication
|
||||
git config --global user.name "${{ github.actor }}"
|
||||
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
|
||||
cat <<- EOF > $HOME/.netrc
|
||||
machine github.com
|
||||
login ${{ github.actor }}
|
||||
password ${{ secrets.GITHUB_TOKEN }}
|
||||
machine api.github.com
|
||||
login ${{ github.actor }}
|
||||
password ${{ secrets.GITHUB_TOKEN }}
|
||||
EOF
|
||||
chmod 600 $HOME/.netrc
|
||||
|
||||
# Create the cherry-pick commit and create the PR for it.
|
||||
git checkout "${{ matrix.branch }}"
|
||||
git switch -c "${BRANCH_NAME}"
|
||||
git cherry-pick -x "${{ github.sha }}"
|
||||
git push --set-upstream origin "${BRANCH_NAME}"
|
||||
GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" gh pr create \
|
||||
--base "${{ matrix.branch }}" \
|
||||
--title "$(git --no-pager show --format="%s" --no-patch HEAD)" \
|
||||
--body "$(git --no-pager show --format="%b" --no-patch HEAD)"
|
|
@ -1,130 +0,0 @@
|
|||
name: git2go CI
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release-*
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
|
||||
build-static:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go: [ '1.11', '1.12', '1.13', '1.14', '1.15', '1.16', '1.17' ]
|
||||
name: Go ${{ matrix.go }}
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- name: Build
|
||||
run: |
|
||||
git submodule update --init
|
||||
sudo apt-get install -y --no-install-recommends libssh2-1-dev
|
||||
make build-libgit2-static
|
||||
- name: Test
|
||||
run: make TEST_ARGS=-test.v test-static
|
||||
|
||||
build-dynamic:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
name: Go (dynamic)
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.17'
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- name: Build
|
||||
run: |
|
||||
git submodule update --init
|
||||
sudo apt-get install -y --no-install-recommends libssh2-1-dev
|
||||
make build-libgit2-dynamic
|
||||
- name: Test
|
||||
run: make TEST_ARGS=-test.v test-dynamic
|
||||
|
||||
build-system-dynamic:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
libgit2:
|
||||
- 'v1.5.0'
|
||||
name: Go (system-wide, dynamic)
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.17'
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- name: Build libgit2 ${{ matrix.libgit2 }}
|
||||
run: |
|
||||
git submodule update --init
|
||||
sudo apt-get install -y --no-install-recommends libssh2-1-dev
|
||||
sudo env BUILD_LIBGIT_REF=${{ matrix.libgit2 }} ./script/build-libgit2.sh --dynamic --system
|
||||
- name: Test
|
||||
run: make TEST_ARGS=-test.v test
|
||||
|
||||
build-system-static:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
name: Go (system-wide, static)
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.17'
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
- name: Build libgit2
|
||||
run: |
|
||||
git submodule update --init
|
||||
sudo apt-get install -y --no-install-recommends libssh2-1-dev
|
||||
sudo ./script/build-libgit2.sh --static --system
|
||||
- name: Test
|
||||
run: go test --count=1 --tags "static,system_libgit2" ./...
|
||||
|
||||
check-generate:
|
||||
name: Check generated files were not modified
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: '1.17'
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Install libgit2 build dependencies
|
||||
run: |
|
||||
git submodule update --init
|
||||
sudo apt-get install -y --no-install-recommends libssh2-1-dev
|
||||
go install golang.org/x/tools/cmd/stringer@latest
|
||||
- name: Generate files
|
||||
run: |
|
||||
export PATH=$(go env GOPATH)/bin:$PATH
|
||||
make generate
|
||||
- name: Check nothing changed
|
||||
run: git diff --quiet --exit-code || (echo "detected changes after generate" ; git status ; exit 1)
|
|
@ -1,28 +0,0 @@
|
|||
name: Tag new releases
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release-*
|
||||
|
||||
jobs:
|
||||
|
||||
tag-release:
|
||||
name: Bump tag in ${{ github.ref }}
|
||||
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Bump version and push tag
|
||||
id: bump-version
|
||||
uses: anothrNick/github-tag-action@43ed073f5c1445ca8b80d920ce2f8fa550ae4e8d
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
WITH_V: true
|
||||
DEFAULT_BUMP: patch
|
||||
TAG_CONTEXT: branch
|
||||
RELEASE_BRANCHES: .*
|
|
@ -1,2 +1,4 @@
|
|||
/static-build/
|
||||
/dynamic-build/
|
||||
|
||||
go.*
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[submodule "vendor/libgit2"]
|
||||
path = vendor/libgit2
|
||||
url = https://github.com/libgit2/libgit2
|
|
@ -8,8 +8,5 @@ package git
|
|||
#cgo CFLAGS: -DLIBGIT2_DYNAMIC
|
||||
#include <git2.h>
|
||||
|
||||
#if LIBGIT2_VER_MAJOR != 1 || LIBGIT2_VER_MINOR < 5 || LIBGIT2_VER_MINOR > 5
|
||||
# error "Invalid libgit2 version; this git2go supports libgit2 between v1.5.0 and v1.5.0"
|
||||
#endif
|
||||
*/
|
||||
import "C"
|
||||
|
|
5
Makefile
5
Makefile
|
@ -1,7 +1,9 @@
|
|||
TEST_ARGS ?= --count=1
|
||||
|
||||
default: test
|
||||
default: goimports test
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
||||
generate: static-build/install/lib/libgit2.a
|
||||
go generate --tags "static" ./...
|
||||
|
@ -10,6 +12,7 @@ generate: static-build/install/lib/libgit2.a
|
|||
# ==============
|
||||
# This uses whatever version of libgit2 can be found in the system.
|
||||
test:
|
||||
go-mod-clean # go install go.wit.com/apps/go-mod-clean@latest
|
||||
go run script/check-MakeGitError-thread-lock.go
|
||||
go test $(TEST_ARGS) ./...
|
||||
|
||||
|
|
12
README.md
12
README.md
|
@ -4,6 +4,18 @@ git2go
|
|||
|
||||
Go bindings for [libgit2](http://libgit2.github.com/).
|
||||
|
||||
### Updated 2024/12/16
|
||||
|
||||
* This package is updated to work against libgit2 version 1.8 on Debian sid
|
||||
* There is one line commented out which needs to be fixed in remote.go
|
||||
* some of the tests seem to run
|
||||
|
||||
```sh
|
||||
go install go.wit.com/apps/go-clone@latest
|
||||
go install go.wit.com/apps/go-mod-clean@latest
|
||||
go-clone --recusive go.wit.com/lib/git2go
|
||||
```
|
||||
|
||||
### Which Go version to use
|
||||
|
||||
Due to the fact that Go 1.11 module versions have semantic meaning and don't necessarily align with libgit2's release schedule, please consult the following table for a mapping between libgit2 and git2go module versions:
|
||||
|
|
9
go.mod
9
go.mod
|
@ -1,9 +0,0 @@
|
|||
module github.com/libgit2/git2go/v34
|
||||
|
||||
go 1.13
|
||||
|
||||
require (
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||
)
|
18
go.sum
18
go.sum
|
@ -1,18 +0,0 @@
|
|||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4 h1:ra2OtmuW0AE5csawV4YXMNGNQQXvLRps3z2Z59OPO+I=
|
||||
github.com/ProtonMail/go-crypto v0.0.0-20221026131551-cf6655e29de4/go.mod h1:UBYPn8k0D56RtnR8RFQMjmh4KrZzWJ5o7Z9SYjossQ8=
|
||||
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
||||
github.com/cloudflare/circl v1.1.0 h1:bZgT/A+cikZnKIwn7xL2OBj012Bmvho/o6RpRvv3GKY=
|
||||
github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
|
@ -479,7 +479,7 @@ func (r *Rebase) Free() {
|
|||
}
|
||||
|
||||
func newRebaseFromC(ptr *C.git_rebase, repo *Repository, opts *C.git_rebase_options) *Rebase {
|
||||
rebase := &Rebase{ptr: ptr, r: repo, options: opts}
|
||||
rebase := &Rebase{ptr: ptr, r: repo, options: opts}
|
||||
runtime.SetFinalizer(rebase, (*Rebase).Free)
|
||||
return rebase
|
||||
}
|
||||
|
|
|
@ -19,73 +19,73 @@ func TestRebaseInMemoryWithConflict(t *testing.T) {
|
|||
defer cleanupTestRepo(t, repo)
|
||||
seedTestRepo(t, repo)
|
||||
|
||||
// Create two branches with common history, where both modify "common-file"
|
||||
// in a conflicting way.
|
||||
_, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
// Create two branches with common history, where both modify "common-file"
|
||||
// in a conflicting way.
|
||||
_, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
checkFatal(t, createBranch(repo, "branch-a"))
|
||||
checkFatal(t, createBranch(repo, "branch-b"))
|
||||
|
||||
checkFatal(t, repo.SetHead("refs/heads/branch-a"))
|
||||
_, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
_, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
|
||||
checkFatal(t, repo.SetHead("refs/heads/branch-b"))
|
||||
_, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
_, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{})
|
||||
checkFatal(t, err)
|
||||
|
||||
branchA, err := repo.LookupBranch("branch-a", BranchLocal)
|
||||
checkFatal(t, err)
|
||||
checkFatal(t, err)
|
||||
onto, err := repo.AnnotatedCommitFromRef(branchA.Reference)
|
||||
checkFatal(t, err)
|
||||
|
||||
// We then rebase "branch-b" onto "branch-a" in-memory, which should result
|
||||
// in a conflict.
|
||||
rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1})
|
||||
checkFatal(t, err)
|
||||
|
||||
_, err = rebase.Next()
|
||||
checkFatal(t, err)
|
||||
|
||||
index, err := rebase.InmemoryIndex()
|
||||
// We then rebase "branch-b" onto "branch-a" in-memory, which should result
|
||||
// in a conflict.
|
||||
rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1})
|
||||
checkFatal(t, err)
|
||||
|
||||
// We simply resolve the conflict and commit the rebase.
|
||||
if !index.HasConflicts() {
|
||||
t.Fatal("expected index to have conflicts")
|
||||
}
|
||||
_, err = rebase.Next()
|
||||
checkFatal(t, err)
|
||||
|
||||
conflict, err := index.Conflict("common-file")
|
||||
checkFatal(t, err)
|
||||
index, err := rebase.InmemoryIndex()
|
||||
checkFatal(t, err)
|
||||
|
||||
resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents"))
|
||||
checkFatal(t, err)
|
||||
// We simply resolve the conflict and commit the rebase.
|
||||
if !index.HasConflicts() {
|
||||
t.Fatal("expected index to have conflicts")
|
||||
}
|
||||
|
||||
resolvedEntry := *conflict.Our
|
||||
resolvedEntry.Id = resolvedBlobID
|
||||
checkFatal(t, index.Add(&resolvedEntry))
|
||||
checkFatal(t, index.RemoveConflict("common-file"))
|
||||
conflict, err := index.Conflict("common-file")
|
||||
checkFatal(t, err)
|
||||
|
||||
var commitID Oid
|
||||
checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message"))
|
||||
checkFatal(t, rebase.Finish())
|
||||
resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents"))
|
||||
checkFatal(t, err)
|
||||
|
||||
// And then assert that we can look up the new merge commit, and that the
|
||||
// "common-file" has the expected contents.
|
||||
commit, err := repo.LookupCommit(&commitID)
|
||||
checkFatal(t, err)
|
||||
if commit.Message() != "rebased message" {
|
||||
t.Fatalf("unexpected commit message %q", commit.Message())
|
||||
}
|
||||
resolvedEntry := *conflict.Our
|
||||
resolvedEntry.Id = resolvedBlobID
|
||||
checkFatal(t, index.Add(&resolvedEntry))
|
||||
checkFatal(t, index.RemoveConflict("common-file"))
|
||||
|
||||
tree, err := commit.Tree()
|
||||
checkFatal(t, err)
|
||||
var commitID Oid
|
||||
checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message"))
|
||||
checkFatal(t, rebase.Finish())
|
||||
|
||||
blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id)
|
||||
checkFatal(t, err)
|
||||
if string(blob.Contents()) != "resolved contents" {
|
||||
t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents()))
|
||||
}
|
||||
// And then assert that we can look up the new merge commit, and that the
|
||||
// "common-file" has the expected contents.
|
||||
commit, err := repo.LookupCommit(&commitID)
|
||||
checkFatal(t, err)
|
||||
if commit.Message() != "rebased message" {
|
||||
t.Fatalf("unexpected commit message %q", commit.Message())
|
||||
}
|
||||
|
||||
tree, err := commit.Tree()
|
||||
checkFatal(t, err)
|
||||
|
||||
blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id)
|
||||
checkFatal(t, err)
|
||||
if string(blob.Contents()) != "resolved contents" {
|
||||
t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents()))
|
||||
}
|
||||
}
|
||||
|
||||
func TestRebaseAbort(t *testing.T) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import "C"
|
|||
import (
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -685,7 +686,7 @@ func (c *RemoteCollection) Create(name string, url string) (*Remote, error) {
|
|||
return remote, nil
|
||||
}
|
||||
|
||||
//CreateWithOptions Creates a repository object with extended options.
|
||||
// CreateWithOptions Creates a repository object with extended options.
|
||||
func (c *RemoteCollection) CreateWithOptions(url string, option *RemoteCreateOptions) (*Remote, error) {
|
||||
remote := &Remote{repo: c.repo}
|
||||
|
||||
|
@ -983,7 +984,9 @@ func populateFetchOptions(copts *C.git_fetch_options, opts *FetchOptions, errorT
|
|||
}
|
||||
populateRemoteCallbacks(&copts.callbacks, &opts.RemoteCallbacks, errorTarget)
|
||||
copts.prune = C.git_fetch_prune_t(opts.Prune)
|
||||
copts.update_fetchhead = cbool(opts.UpdateFetchhead)
|
||||
fmt.Println("populateFetchOptions() is broken. fixme!")
|
||||
// fix this line: ./remote.go:988:27: cannot use cbool(opts.UpdateFetchhead) (value of type _Ctype_int) as _Ctype_uint value in assignment
|
||||
// copts.update_fetchhead = cbool(opts.UpdateFetchhead)
|
||||
copts.download_tags = C.git_remote_autotag_option_t(opts.DownloadTags)
|
||||
|
||||
copts.custom_headers = C.git_strarray{
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit fbea439d4b6fc91c6b619d01b85ab3b7746e4c19
|
Loading…
Reference in New Issue