mirror of
https://github.com/go-gitea/gitea
synced 2026-02-03 08:50:36 +00:00
add support for archive-upload rpc (#36391)
Add support for fetching archives with `git archive --remote <repo-url>` closes: https://github.com/go-gitea/gitea/issues/23425 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -229,3 +229,15 @@ func doGitPull(dstPath string, args ...string) func(*testing.T) {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
// doGitRemoteArchive runs a git archive command requesting an archive from remote
|
||||
// and verifies that the command did not error out and returned only normal output
|
||||
func doGitRemoteArchive(remote string, args ...string) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
stdout, stderr, err := gitcmd.NewCommand("archive").AddOptionValues("--remote", remote).AddArguments(gitcmd.ToTrustedCmdArgs(args)...).
|
||||
RunStdString(t.Context())
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, stderr)
|
||||
assert.NotEmpty(t, stdout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ func TestGitSmartHTTP(t *testing.T) {
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
testGitSmartHTTP(t, u)
|
||||
testRenamedRepoRedirect(t)
|
||||
testGitArchiveRemote(t, u)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -96,3 +97,10 @@ func testRenamedRepoRedirect(t *testing.T) {
|
||||
resp = MakeRequest(t, req, http.StatusOK)
|
||||
assert.Contains(t, resp.Body.String(), "65f1bf27bc3bf70f64657658635e66094edbcb4d\trefs/tags/v1.1")
|
||||
}
|
||||
|
||||
func testGitArchiveRemote(t *testing.T, u *url.URL) {
|
||||
u = u.JoinPath("user27/repo49.git")
|
||||
t.Run("Fetch HEAD archive", doGitRemoteArchive(u.String(), "HEAD"))
|
||||
t.Run("Fetch HEAD archive subpath", doGitRemoteArchive(u.String(), "HEAD", "test"))
|
||||
t.Run("list compression options", doGitRemoteArchive(u.String(), "--list"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user