mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-30 18:15:52 +01:00
Remove deprecated api calls
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.web;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
@@ -40,23 +40,21 @@ import sonia.scm.plugin.Extension;
|
||||
*/
|
||||
@Extension
|
||||
public class GitUserAgentProvider implements UserAgentProvider {
|
||||
|
||||
|
||||
private static final String PREFIX_JGIT = "jgit/";
|
||||
|
||||
@VisibleForTesting
|
||||
static final UserAgent JGIT = UserAgent.scmClient("JGit")
|
||||
.browser(false)
|
||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||
.build();
|
||||
|
||||
|
||||
private static final String PREFIX_REGULAR = "git/";
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
static final UserAgent GIT = UserAgent.scmClient("Git")
|
||||
.browser(false)
|
||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||
.build();
|
||||
|
||||
|
||||
private static final String PREFIX_LFS = "git-lfs/";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -65,7 +63,7 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
.build();
|
||||
|
||||
private static final String SUFFIX_MSYSGIT = "msysgit";
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
static final UserAgent MSYSGIT = UserAgent.scmClient("msysGit")
|
||||
.basicAuthenticationCharset(Charsets.UTF_8)
|
||||
@@ -78,7 +76,7 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
@Override
|
||||
public UserAgent parseUserAgent(String userAgentString) {
|
||||
String lowerUserAgent = toLower(userAgentString);
|
||||
|
||||
|
||||
if (isJGit(lowerUserAgent)) {
|
||||
return JGIT;
|
||||
} else if (isMsysGit(lowerUserAgent)) {
|
||||
@@ -91,23 +89,23 @@ public class GitUserAgentProvider implements UserAgentProvider {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String toLower(String value) {
|
||||
return Strings.nullToEmpty(value).toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
|
||||
private boolean isJGit(String userAgent) {
|
||||
return userAgent.startsWith(PREFIX_JGIT);
|
||||
}
|
||||
|
||||
|
||||
private boolean isMsysGit(String userAgent) {
|
||||
return userAgent.startsWith(PREFIX_REGULAR) && userAgent.contains(SUFFIX_MSYSGIT);
|
||||
}
|
||||
|
||||
|
||||
private boolean isGitLFS(String userAgent) {
|
||||
return userAgent.startsWith(PREFIX_LFS);
|
||||
}
|
||||
|
||||
|
||||
private boolean isGit(String userAgent) {
|
||||
return userAgent.startsWith(PREFIX_REGULAR);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user