forked from go-git/go-git
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow unsupported multi_ack capability
Azure DevOps requires capabilities multi_ack / multi_ack_detailed, which are not fully implemented and by default are included in transport.UnsupportedCapabilities. The initial clone operations require a full download of the repository, and therefore those unsupported capabilities are not as crucial, so by removing them from that list allows for the first clone to work successfully. Additional fetches will yield issues, therefore to support that repository users have to work from a clean clone until those capabilities are fully supported. Commits and pushes back into the repository have also been tested and work fine. This change adds an example for cloning Azure DevOps repositories. Signed-off-by: Paulo Gomes <pjbgf@linux.com> (cherry picked from commit 9c7d2df)
- Loading branch information
Showing
5 changed files
with
97 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
git "github.com/go-git/go-git/v5" | ||
. "github.com/go-git/go-git/v5/_examples" | ||
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability" | ||
"github.com/go-git/go-git/v5/plumbing/transport" | ||
"github.com/go-git/go-git/v5/plumbing/transport/http" | ||
) | ||
|
||
func main() { | ||
CheckArgs("<url>", "<directory>", "<azuredevops_username>", "<azuredevops_password>") | ||
url, directory, username, password := os.Args[1], os.Args[2], os.Args[3], os.Args[4] | ||
|
||
// Clone the given repository to the given directory | ||
Info("git clone %s %s", url, directory) | ||
|
||
// Azure DevOps requires capabilities multi_ack / multi_ack_detailed, | ||
// which are not fully implemented and by default are included in | ||
// transport.UnsupportedCapabilities. | ||
// | ||
// The initial clone operations require a full download of the repository, | ||
// and therefore those unsupported capabilities are not as crucial, so | ||
// by removing them from that list allows for the first clone to work | ||
// successfully. | ||
// | ||
// Additional fetches will yield issues, therefore work always from a clean | ||
// clone until those capabilities are fully supported. | ||
// | ||
// New commits and pushes against a remote worked without any issues. | ||
transport.UnsupportedCapabilities = []capability.Capability{ | ||
capability.ThinPack, | ||
} | ||
|
||
r, err := git.PlainClone(directory, false, &git.CloneOptions{ | ||
Auth: &http.BasicAuth{ | ||
Username: username, | ||
Password: password, | ||
}, | ||
URL: url, | ||
Progress: os.Stdout, | ||
}) | ||
CheckIfError(err) | ||
|
||
// ... retrieving the branch being pointed by HEAD | ||
ref, err := r.Head() | ||
CheckIfError(err) | ||
// ... retrieving the commit object | ||
commit, err := r.CommitObject(ref.Hash()) | ||
CheckIfError(err) | ||
|
||
fmt.Println(commit) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters