| commit | eaa7b361c3cf3040503d9b12a5281455acb3a8ba | [log] [tgz] |
|---|---|---|
| author | Thomas Broyer <t.broyer@ltgt.net> | Thu Oct 07 13:12:35 2021 +0200 |
| committer | Thomas Broyer <t.broyer@ltgt.net> | Thu Oct 07 13:19:34 2021 +0200 |
| tree | 283ca9f281d9948d9303c1bb86191ce7468670bc | |
| parent | 929833bd0044012a51dddea38954d35ca1ef2235 [diff] |
Fix compatibility with git-lfs v3 git-lfs v3 introduced a breaking change in the way it calls git-lfs-authenticate over SSH [1,2] in that, for ssh:// URLs like the ones used with Gerrit (to specify the custom 29418 port) it will no longer strip the first "/", so it'll pass "/projectname" when git-lfs v2 passed "projectname". This results in the generated token to later be rejected at the HTTP endpoints because the 'project' doesn't match. The fix here is to simply strip the leading "/", if any, in the git-lfs-authenticate command. [1] https://github.com/git-lfs/git-lfs/blob/main/CHANGELOG.md#300-24-sep-2021 [2] https://github.com/git-lfs/git-lfs/commit/a0190a60205bc6223d1d9028c34585583721c7ee Bug: Issue 15139 Change-Id: I875c460ee969a0c6740af6054a5a84d9ca354d1b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsSshAuth.java b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsSshAuth.java index 3dd7a86..16f204a 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsSshAuth.java +++ b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsSshAuth.java
@@ -52,6 +52,9 @@ URL url = new URL(canonicalWebUrl); String path = url.getPath(); String project = args.get(0); + if (project.startsWith("/")) { + project = project.substring(1); + } String operation = args.get(1); StringBuilder href = new StringBuilder(url.getProtocol())