mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-26 00:56:09 +02:00
Bugfix for go-git client issue
This commit is contained in:
committed by
René Pfeuffer
parent
59a9d4939a
commit
7858316a63
2
gradle/changelog/gogit_client_support.yaml
Normal file
2
gradle/changelog/gogit_client_support.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Support for go-git user agents (e.g. ArgoCD ≥ 2.14)
|
||||
@@ -69,7 +69,12 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||
.build();
|
||||
|
||||
private static final String PREFIX_GOGIT = "go-git/";
|
||||
|
||||
@VisibleForTesting
|
||||
static final UserAgent GOGIT = UserAgent.scmClient("go-git")
|
||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||
.build();
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
@@ -85,6 +90,8 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
return GIT_LFS;
|
||||
} else if (isGit(lowerUserAgent)) {
|
||||
return GIT;
|
||||
} else if (isGoGit(lowerUserAgent)) {
|
||||
return GOGIT;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -109,4 +116,6 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
private boolean isGit(String userAgent) {
|
||||
return userAgent.startsWith(PREFIX_REGULAR);
|
||||
}
|
||||
|
||||
private boolean isGoGit(String userAgent) { return userAgent.startsWith(PREFIX_GOGIT); }
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class GitUserAgentProviderTest {
|
||||
assertEquals(GitUserAgentProvider.JGIT, parse("jgit/4.5.2"));
|
||||
assertEquals(GitUserAgentProvider.GIT_LFS, parse("git-lfs/2.0.1 (GitHub; windows amd64; go 1.8; git 678cdbd4)"));
|
||||
assertEquals(GitUserAgentProvider.MSYSGIT, parse("git/1.8.3.msysgit.0"));
|
||||
assertEquals(GitUserAgentProvider.GOGIT, parse("go-git/5.x"));
|
||||
assertNull(parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user