aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2021-08-24 11:47:09 -0500
committerGitHub <noreply@github.com>2021-08-24 11:47:09 -0500
commit648464b504755ee96187692fbe59acc2eec5bddf (patch)
treeaa25fbd8c8d9cb975d6eb53094098d5a33aa7afa /modules/git
parentd22cb600edc2605bd8be25c9079a5ce2c6643547 (diff)
downloadgitea-648464b504755ee96187692fbe59acc2eec5bddf.tar.gz
gitea-648464b504755ee96187692fbe59acc2eec5bddf.zip
Add bundle download for repository (#14538)
* Add bundle download Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix fmt Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix build tags Signed-off-by: jolheiser <john.olheiser@gmail.com> * Download specific commit Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/blob_gogit.go1
-rw-r--r--modules/git/blob_nogogit.go1
-rw-r--r--modules/git/command_test.go1
-rw-r--r--modules/git/commit_convert_gogit.go1
-rw-r--r--modules/git/commit_info_gogit.go1
-rw-r--r--modules/git/commit_info_nogogit.go1
-rw-r--r--modules/git/last_commit_cache_gogit.go1
-rw-r--r--modules/git/last_commit_cache_nogogit.go1
-rw-r--r--modules/git/notes_gogit.go1
-rw-r--r--modules/git/notes_nogogit.go1
-rw-r--r--modules/git/parse_gogit.go1
-rw-r--r--modules/git/parse_gogit_test.go1
-rw-r--r--modules/git/parse_nogogit.go1
-rw-r--r--modules/git/parse_nogogit_test.go1
-rw-r--r--modules/git/pipeline/lfs.go1
-rw-r--r--modules/git/pipeline/lfs_nogogit.go1
-rw-r--r--modules/git/repo.go31
-rw-r--r--modules/git/repo_archive.go4
-rw-r--r--modules/git/repo_base_gogit.go1
-rw-r--r--modules/git/repo_base_nogogit.go1
-rw-r--r--modules/git/repo_blob_gogit.go1
-rw-r--r--modules/git/repo_blob_nogogit.go1
-rw-r--r--modules/git/repo_branch_gogit.go1
-rw-r--r--modules/git/repo_branch_nogogit.go1
-rw-r--r--modules/git/repo_commit_gogit.go1
-rw-r--r--modules/git/repo_commit_nogogit.go1
-rw-r--r--modules/git/repo_commitgraph_gogit.go1
-rw-r--r--modules/git/repo_language_stats_gogit.go1
-rw-r--r--modules/git/repo_language_stats_nogogit.go1
-rw-r--r--modules/git/repo_ref_gogit.go1
-rw-r--r--modules/git/repo_ref_nogogit.go1
-rw-r--r--modules/git/repo_tag_gogit.go1
-rw-r--r--modules/git/repo_tag_nogogit.go1
-rw-r--r--modules/git/repo_tree_gogit.go1
-rw-r--r--modules/git/repo_tree_nogogit.go1
-rw-r--r--modules/git/sha1_gogit.go1
-rw-r--r--modules/git/sha1_nogogit.go1
-rw-r--r--modules/git/signature_gogit.go1
-rw-r--r--modules/git/signature_nogogit.go1
-rw-r--r--modules/git/tree_blob_gogit.go1
-rw-r--r--modules/git/tree_blob_nogogit.go1
-rw-r--r--modules/git/tree_entry_gogit.go1
-rw-r--r--modules/git/tree_entry_nogogit.go1
-rw-r--r--modules/git/tree_entry_test.go1
-rw-r--r--modules/git/tree_gogit.go1
-rw-r--r--modules/git/tree_nogogit.go1
46 files changed, 79 insertions, 0 deletions
diff --git a/modules/git/blob_gogit.go b/modules/git/blob_gogit.go
index 7a82eb5c37..ef7a90c3f4 100644
--- a/modules/git/blob_gogit.go
+++ b/modules/git/blob_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/blob_nogogit.go b/modules/git/blob_nogogit.go
index 5b42920ebe..26815a63f1 100644
--- a/modules/git/blob_nogogit.go
+++ b/modules/git/blob_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/command_test.go b/modules/git/command_test.go
index 00801ae31f..58d616a038 100644
--- a/modules/git/command_test.go
+++ b/modules/git/command_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build race
// +build race
package git
diff --git a/modules/git/commit_convert_gogit.go b/modules/git/commit_convert_gogit.go
index be2b948b36..b328b3c0ed 100644
--- a/modules/git/commit_convert_gogit.go
+++ b/modules/git/commit_convert_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/commit_info_gogit.go b/modules/git/commit_info_gogit.go
index a8006dcef2..8b82f3f66c 100644
--- a/modules/git/commit_info_gogit.go
+++ b/modules/git/commit_info_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/commit_info_nogogit.go b/modules/git/commit_info_nogogit.go
index 060ecba261..f57355d16e 100644
--- a/modules/git/commit_info_nogogit.go
+++ b/modules/git/commit_info_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/last_commit_cache_gogit.go b/modules/git/last_commit_cache_gogit.go
index b8e0db46a9..fb09af6f2a 100644
--- a/modules/git/last_commit_cache_gogit.go
+++ b/modules/git/last_commit_cache_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/last_commit_cache_nogogit.go b/modules/git/last_commit_cache_nogogit.go
index faf6e23fa8..f71e7350a1 100644
--- a/modules/git/last_commit_cache_nogogit.go
+++ b/modules/git/last_commit_cache_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/notes_gogit.go b/modules/git/notes_gogit.go
index 9da45ca65c..84f66d86bf 100644
--- a/modules/git/notes_gogit.go
+++ b/modules/git/notes_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go
index 697f998288..9a54b48106 100644
--- a/modules/git/notes_nogogit.go
+++ b/modules/git/notes_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/parse_gogit.go b/modules/git/parse_gogit.go
index a50ebec3dd..c42e32929e 100644
--- a/modules/git/parse_gogit.go
+++ b/modules/git/parse_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/parse_gogit_test.go b/modules/git/parse_gogit_test.go
index c6374133c0..c27f5172d5 100644
--- a/modules/git/parse_gogit_test.go
+++ b/modules/git/parse_gogit_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/parse_nogogit.go b/modules/git/parse_nogogit.go
index 667111ec4a..dd5554b5dd 100644
--- a/modules/git/parse_nogogit.go
+++ b/modules/git/parse_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/parse_nogogit_test.go b/modules/git/parse_nogogit_test.go
index 502c38d4e8..5f58237de8 100644
--- a/modules/git/parse_nogogit_test.go
+++ b/modules/git/parse_nogogit_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/pipeline/lfs.go b/modules/git/pipeline/lfs.go
index d47b7d91ea..46a48b710c 100644
--- a/modules/git/pipeline/lfs.go
+++ b/modules/git/pipeline/lfs.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package pipeline
diff --git a/modules/git/pipeline/lfs_nogogit.go b/modules/git/pipeline/lfs_nogogit.go
index d3696fcda2..a441e37b60 100644
--- a/modules/git/pipeline/lfs_nogogit.go
+++ b/modules/git/pipeline/lfs_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package pipeline
diff --git a/modules/git/repo.go b/modules/git/repo.go
index f2bbbf4716..e7d42dacb1 100644
--- a/modules/git/repo.go
+++ b/modules/git/repo.go
@@ -13,6 +13,7 @@ import (
"net/url"
"os"
"path"
+ "path/filepath"
"strconv"
"strings"
"time"
@@ -415,3 +416,33 @@ func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string
return DivergeObject{ahead, behind}, nil
}
+
+// CreateBundle create bundle content to the target path
+func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.Writer) error {
+ tmp, err := os.MkdirTemp(os.TempDir(), "gitea-bundle")
+ if err != nil {
+ return err
+ }
+ defer os.RemoveAll(tmp)
+
+ tmpFile := filepath.Join(tmp, "bundle")
+ args := []string{
+ "bundle",
+ "create",
+ tmpFile,
+ commit,
+ }
+ _, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)
+ if err != nil {
+ return err
+ }
+
+ fi, err := os.Open(tmpFile)
+ if err != nil {
+ return err
+ }
+ defer fi.Close()
+
+ _, err = io.Copy(out, fi)
+ return err
+}
diff --git a/modules/git/repo_archive.go b/modules/git/repo_archive.go
index 07003aa6b2..83df082ad3 100644
--- a/modules/git/repo_archive.go
+++ b/modules/git/repo_archive.go
@@ -21,6 +21,8 @@ const (
ZIP ArchiveType = iota + 1
// TARGZ tar gz archive type
TARGZ
+ // BUNDLE bundle archive type
+ BUNDLE
)
// String converts an ArchiveType to string
@@ -30,6 +32,8 @@ func (a ArchiveType) String() string {
return "zip"
case TARGZ:
return "tar.gz"
+ case BUNDLE:
+ return "bundle"
}
return "unknown"
}
diff --git a/modules/git/repo_base_gogit.go b/modules/git/repo_base_gogit.go
index 6186824c0b..afa5383b11 100644
--- a/modules/git/repo_base_gogit.go
+++ b/modules/git/repo_base_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go
index 1675967d18..22c4dfdcb3 100644
--- a/modules/git/repo_base_nogogit.go
+++ b/modules/git/repo_base_nogogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_blob_gogit.go b/modules/git/repo_blob_gogit.go
index 485c233ff8..b11e9f58fe 100644
--- a/modules/git/repo_blob_gogit.go
+++ b/modules/git/repo_blob_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_blob_nogogit.go b/modules/git/repo_blob_nogogit.go
index afb08d29cb..775b3835dd 100644
--- a/modules/git/repo_blob_nogogit.go
+++ b/modules/git/repo_blob_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_branch_gogit.go b/modules/git/repo_branch_gogit.go
index e8386b2dbd..6bf14b3999 100644
--- a/modules/git/repo_branch_gogit.go
+++ b/modules/git/repo_branch_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_branch_nogogit.go b/modules/git/repo_branch_nogogit.go
index 7d10b8ba0f..666ca81c1e 100644
--- a/modules/git/repo_branch_nogogit.go
+++ b/modules/git/repo_branch_nogogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_commit_gogit.go b/modules/git/repo_commit_gogit.go
index 2f9b1c4206..175b6e6446 100644
--- a/modules/git/repo_commit_gogit.go
+++ b/modules/git/repo_commit_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_commit_nogogit.go b/modules/git/repo_commit_nogogit.go
index afd5166f1d..b7e49a6501 100644
--- a/modules/git/repo_commit_nogogit.go
+++ b/modules/git/repo_commit_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_commitgraph_gogit.go b/modules/git/repo_commitgraph_gogit.go
index 6773109451..84a2edb664 100644
--- a/modules/git/repo_commitgraph_gogit.go
+++ b/modules/git/repo_commitgraph_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_language_stats_gogit.go b/modules/git/repo_language_stats_gogit.go
index 20a7b061f2..0a4cfbbc7b 100644
--- a/modules/git/repo_language_stats_gogit.go
+++ b/modules/git/repo_language_stats_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_language_stats_nogogit.go b/modules/git/repo_language_stats_nogogit.go
index 1684f21d16..7425e2dbb1 100644
--- a/modules/git/repo_language_stats_nogogit.go
+++ b/modules/git/repo_language_stats_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_ref_gogit.go b/modules/git/repo_ref_gogit.go
index 2e83e6c462..9f0e11366f 100644
--- a/modules/git/repo_ref_gogit.go
+++ b/modules/git/repo_ref_gogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_ref_nogogit.go b/modules/git/repo_ref_nogogit.go
index 540961592b..ec0c5ec4ca 100644
--- a/modules/git/repo_ref_nogogit.go
+++ b/modules/git/repo_ref_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_tag_gogit.go b/modules/git/repo_tag_gogit.go
index 3ac097c9a8..3022fe96f7 100644
--- a/modules/git/repo_tag_gogit.go
+++ b/modules/git/repo_tag_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_tag_nogogit.go b/modules/git/repo_tag_nogogit.go
index a9e122aeaa..0170f0cc76 100644
--- a/modules/git/repo_tag_nogogit.go
+++ b/modules/git/repo_tag_nogogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/repo_tree_gogit.go b/modules/git/repo_tree_gogit.go
index d878f5e7a7..2ddffcf79b 100644
--- a/modules/git/repo_tree_gogit.go
+++ b/modules/git/repo_tree_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/repo_tree_nogogit.go b/modules/git/repo_tree_nogogit.go
index 967f8aea3f..9d4268b13a 100644
--- a/modules/git/repo_tree_nogogit.go
+++ b/modules/git/repo_tree_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/sha1_gogit.go b/modules/git/sha1_gogit.go
index 5953af58bf..30290f14b7 100644
--- a/modules/git/sha1_gogit.go
+++ b/modules/git/sha1_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/sha1_nogogit.go b/modules/git/sha1_nogogit.go
index 09b5baacd5..53665fc921 100644
--- a/modules/git/sha1_nogogit.go
+++ b/modules/git/sha1_nogogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/signature_gogit.go b/modules/git/signature_gogit.go
index 804c0074d3..903a48133f 100644
--- a/modules/git/signature_gogit.go
+++ b/modules/git/signature_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/signature_nogogit.go b/modules/git/signature_nogogit.go
index 753d87b605..c6fe8e6d1a 100644
--- a/modules/git/signature_nogogit.go
+++ b/modules/git/signature_nogogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/tree_blob_gogit.go b/modules/git/tree_blob_gogit.go
index 93ebc8a367..a8d619cd18 100644
--- a/modules/git/tree_blob_gogit.go
+++ b/modules/git/tree_blob_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/tree_blob_nogogit.go b/modules/git/tree_blob_nogogit.go
index fdd8d79c8b..df23ff01b4 100644
--- a/modules/git/tree_blob_nogogit.go
+++ b/modules/git/tree_blob_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/tree_entry_gogit.go b/modules/git/tree_entry_gogit.go
index 219251a77e..20e767eea1 100644
--- a/modules/git/tree_entry_gogit.go
+++ b/modules/git/tree_entry_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/tree_entry_nogogit.go b/modules/git/tree_entry_nogogit.go
index 41356ceba2..288ec4db6e 100644
--- a/modules/git/tree_entry_nogogit.go
+++ b/modules/git/tree_entry_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git
diff --git a/modules/git/tree_entry_test.go b/modules/git/tree_entry_test.go
index 3382de4102..402c345887 100644
--- a/modules/git/tree_entry_test.go
+++ b/modules/git/tree_entry_test.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/tree_gogit.go b/modules/git/tree_gogit.go
index 79132c5548..bc02088366 100644
--- a/modules/git/tree_gogit.go
+++ b/modules/git/tree_gogit.go
@@ -3,6 +3,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build gogit
// +build gogit
package git
diff --git a/modules/git/tree_nogogit.go b/modules/git/tree_nogogit.go
index 9661d8faea..3d3fd26ece 100644
--- a/modules/git/tree_nogogit.go
+++ b/modules/git/tree_nogogit.go
@@ -2,6 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
+//go:build !gogit
// +build !gogit
package git