]> source.dussan.org Git - gitea.git/commitdiff
Add bundle download for repository (#14538)
authorJohn Olheiser <john.olheiser@gmail.com>
Tue, 24 Aug 2021 16:47:09 +0000 (11:47 -0500)
committerGitHub <noreply@github.com>
Tue, 24 Aug 2021 16:47:09 +0000 (11:47 -0500)
* 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>
83 files changed:
build.go
build/generate-bindata.go
build/generate-emoji.go
build/generate-gitignores.go
build/generate-licenses.go
build/gocovmerge.go
cmd/embedded.go
cmd/embedded_stub.go
modules/auth/pam/pam.go
modules/auth/pam/pam_stub.go
modules/auth/pam/pam_test.go
modules/git/blob_gogit.go
modules/git/blob_nogogit.go
modules/git/command_test.go
modules/git/commit_convert_gogit.go
modules/git/commit_info_gogit.go
modules/git/commit_info_nogogit.go
modules/git/last_commit_cache_gogit.go
modules/git/last_commit_cache_nogogit.go
modules/git/notes_gogit.go
modules/git/notes_nogogit.go
modules/git/parse_gogit.go
modules/git/parse_gogit_test.go
modules/git/parse_nogogit.go
modules/git/parse_nogogit_test.go
modules/git/pipeline/lfs.go
modules/git/pipeline/lfs_nogogit.go
modules/git/repo.go
modules/git/repo_archive.go
modules/git/repo_base_gogit.go
modules/git/repo_base_nogogit.go
modules/git/repo_blob_gogit.go
modules/git/repo_blob_nogogit.go
modules/git/repo_branch_gogit.go
modules/git/repo_branch_nogogit.go
modules/git/repo_commit_gogit.go
modules/git/repo_commit_nogogit.go
modules/git/repo_commitgraph_gogit.go
modules/git/repo_language_stats_gogit.go
modules/git/repo_language_stats_nogogit.go
modules/git/repo_ref_gogit.go
modules/git/repo_ref_nogogit.go
modules/git/repo_tag_gogit.go
modules/git/repo_tag_nogogit.go
modules/git/repo_tree_gogit.go
modules/git/repo_tree_nogogit.go
modules/git/sha1_gogit.go
modules/git/sha1_nogogit.go
modules/git/signature_gogit.go
modules/git/signature_nogogit.go
modules/git/tree_blob_gogit.go
modules/git/tree_blob_nogogit.go
modules/git/tree_entry_gogit.go
modules/git/tree_entry_nogogit.go
modules/git/tree_entry_test.go
modules/git/tree_gogit.go
modules/git/tree_nogogit.go
modules/graceful/manager_unix.go
modules/graceful/manager_windows.go
modules/graceful/net_unix.go
modules/graceful/net_windows.go
modules/graceful/restart_unix.go
modules/lfs/pointer_scanner_gogit.go
modules/lfs/pointer_scanner_nogogit.go
modules/options/dynamic.go
modules/options/options_bindata.go
modules/options/static.go
modules/public/dynamic.go
modules/public/public_bindata.go
modules/public/static.go
modules/setting/database_sqlite.go
modules/svg/discover_bindata.go
modules/svg/discover_nobindata.go
modules/templates/dynamic.go
modules/templates/static.go
modules/templates/templates_bindata.go
options/locale/locale_en-US.ini
routers/private/manager_unix.go
routers/private/manager_windows.go
services/archiver/archiver.go
services/auth/placeholder.go
templates/repo/home.tmpl
tools/fuzz.go

index b843465dca612e6ee732cb517dea2d5577920c46..aa561413407bc07ba8016557b823185a03784459 100644 (file)
--- a/build.go
+++ b/build.go
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
-//+build vendor
+//go:build vendor
+// +build vendor
 
 package main
 
index fa1669fcf9fb149b4e0e4194b97169e15b872cc4..efd172f779aac9097b86ba2cf770035d11914a81 100644 (file)
@@ -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 ignore
 // +build ignore
 
 package main
index c97d865bdc294599d0261946f8a17f7ae0a3b86c..da4e12373ce092101048faaa66cd888baf1f3787 100644 (file)
@@ -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 ignore
 // +build ignore
 
 package main
index 846bb076365d2e4a2fc3229b705ab42bb2aa9acf..d0b972e803e0064907e50286625ddd2ef3461a73 100644 (file)
@@ -1,3 +1,4 @@
+//go:build ignore
 // +build ignore
 
 package main
index 9dd13adf9a7bc856073d23855f78222e2a778177..4009a0351d60a473e5d46eb0742054baf2005f8a 100644 (file)
@@ -1,3 +1,4 @@
+//go:build ignore
 // +build ignore
 
 package main
index 65d6f2cd6ccc38d8b4fa9f65707300249a6f6cd2..b38cf5ea3d5cec4bfd41444b624b37661346eed5 100644 (file)
@@ -6,6 +6,7 @@
 // gocovmerge takes the results from multiple `go test -coverprofile` runs and
 // merges them into one profile
 
+//go:build ignore
 // +build ignore
 
 package main
index 528f32402e1a2d55d642251b2ada8c8fa5650dc4..2aeaba4786fc4b9d1a3bea2f8352c1797ea5c1ec 100644 (file)
@@ -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 bindata
 // +build bindata
 
 package cmd
index 1f9af7b86b123b85aa1a2ef63af2f09a9d9218cb..0e9e3e6ec3e14ede9932b2a2ce1f17ba657d2471 100644 (file)
@@ -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 !bindata
 // +build !bindata
 
 package cmd
index f21602c6b5663f86eb50df92e9373b3723d074d1..73ecae0c2c29f5a3fe410dba66301eaf560d56b1 100644 (file)
@@ -1,9 +1,10 @@
-// +build pam
-
 // Copyright 2014 The Gogs Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build pam
+// +build pam
+
 package pam
 
 import (
index 02d8da3c57ad2d7fa6f7172cd5f34736fc9cbb2e..815ccf2b0e2dbb86c0f46285e36cbebf4bb39999 100644 (file)
@@ -1,9 +1,10 @@
-// +build !pam
-
 // Copyright 2014 The Gogs Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !pam
+// +build !pam
+
 package pam
 
 import (
index fa16ff0fe78cda95da7e39ed1064457924274e13..d6d78a748b7aab0d20553a636be1f7e216688e13 100644 (file)
@@ -1,3 +1,4 @@
+//go:build pam
 // +build pam
 
 // Copyright 2021 The Gitea Authors. All rights reserved.
index 7a82eb5c3706f8d0048ec626e09fa9af4bff3c84..ef7a90c3f40b87fb893cd4f0378a0c2fb67ff022 100644 (file)
@@ -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
index 5b42920ebe1d4931f3375fbff0bb1ebc6dd29158..26815a63f1abb5a10c9ef5e6f3644813bf02babf 100644 (file)
@@ -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
index 00801ae31ff258d3f0383cf463890d149fd84d8e..58d616a0385d5306acd5119b90f65d14ec25ee3c 100644 (file)
@@ -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
index be2b948b363f38e8e1c0291286a15a0abcf65d4d..b328b3c0edfb76f8bed805217e49de824d3cb670 100644 (file)
@@ -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
index a8006dcef2e64aab7d59b1d51f1f02f2c51a4e1e..8b82f3f66cbaea09b136a28acd54592562a956c6 100644 (file)
@@ -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
index 060ecba26190be4a28366c4fdb605a8b22bee80c..f57355d16ed40e0774ebfc5064cbbea84f7b0f46 100644 (file)
@@ -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
index b8e0db46a92652f199af633d6625315f209bcec0..fb09af6f2a762e1b0f172d462ab7f2f4bba401c2 100644 (file)
@@ -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
index faf6e23fa8166cd3b921abca2b3b435ac72ac355..f71e7350a1feca4d403f501bf33db4154ad07d49 100644 (file)
@@ -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
index 9da45ca65c25d704f1324690e7eecdc154d3d854..84f66d86bf67b953c39f0771ade366c39bafa0b3 100644 (file)
@@ -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
index 697f998288f5de7b8ee38d1fce95b53a2a159edd..9a54b4810638ea46f8e7bb1497094932220d427e 100644 (file)
@@ -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
index a50ebec3dd72be3b4235754bc5977444451ba841..c42e32929e457a6b4d4d5fbe2075ca6f4c3fcad9 100644 (file)
@@ -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
index c6374133c0951f0f1b4ceacee8caf354e2eefdc2..c27f5172d5e465efedd0b6b225e4503030536f0e 100644 (file)
@@ -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
index 667111ec4a313bb4fb62bcfc7aded8f65884e1b6..dd5554b5dd747bb6dac304998ccc22eb428fbb2c 100644 (file)
@@ -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
index 502c38d4e8d9f34f95433a34fe8d9049f9c21efb..5f58237de832e71318e1eabd77d6851846c9d4f2 100644 (file)
@@ -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
index d47b7d91ea86cb6727bce3af6d77dc37525dd13e..46a48b710c6f9ef006ea932096ce96a4c49e9506 100644 (file)
@@ -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
index d3696fcda219c1fbbb593957e58410ffc66ef097..a441e37b60e1e5ebe57628f8ac7ccd8a5e2f01fc 100644 (file)
@@ -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
index f2bbbf4716e95440e713041fd8880a523855c1d6..e7d42dacb165d9b477fbd7ebe289ba9eca6401b2 100644 (file)
@@ -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
+}
index 07003aa6b2c1385f04d6ed86b983b7c4e473da8a..83df082ad3da50e99932872ba1f0fba7e3ca00a2 100644 (file)
@@ -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"
 }
index 6186824c0b9f66e07c4835e35276ab14b98b4ace..afa5383b1164b1d4fa7b57366fc95c31b93c1d5c 100644 (file)
@@ -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
index 1675967d181bcbcb8e261b1699e557acc6afeefd..22c4dfdcb3b8dc18d418f890088b75253bc1d565 100644 (file)
@@ -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
index 485c233ff8914e78ee3588ef9cf256581aaea9af..b11e9f58fe9bfbf786c2f2f7663e3bf35bab048f 100644 (file)
@@ -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
index afb08d29cb9826462cd2dfeb4de2dfb68419a42d..775b3835dd5de8f44586628c51bcf64c24c61309 100644 (file)
@@ -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
index e8386b2dbd98fade940e4bfd69e143f6539448bd..6bf14b399986516c1fa064a885cf528b5779854f 100644 (file)
@@ -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
index 7d10b8ba0faeb1227b3ed51d1b4d2c1a54100302..666ca81c1e8f83bc538cfcca9ed681da26baff0d 100644 (file)
@@ -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
index 2f9b1c4206f4287411dbc5c19001a37bafa3562b..175b6e644660c2570a887a0b2ccfe1146bdcc98f 100644 (file)
@@ -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
index afd5166f1d549dd6e85e06148a21ff5662e55a21..b7e49a6501b17141fd2e85d4012ac79c517e8106 100644 (file)
@@ -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
index 67731094513cc3b6ae191fdadde63927479d1ca2..84a2edb664bb441094d0825af7ee790d4b0e2af0 100644 (file)
@@ -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
index 20a7b061f21070888fb189db3104b31ecdde5f10..0a4cfbbc7bfb9fbb3d44da7c584ad3bad38d16df 100644 (file)
@@ -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
index 1684f21d1675d311d9eff52d9ae2921af5527d0d..7425e2dbb1d1ba512337c288316f1cda1728276c 100644 (file)
@@ -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
index 2e83e6c4627beaa12d0ef5ab6cd888119c59fe8e..9f0e11366f6778e352a27cb52a7e96939a71f19e 100644 (file)
@@ -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
index 540961592b4c084f323ec4f6f4bec72077cbd70b..ec0c5ec4cad301a314f3eea1141a45a0a017a248 100644 (file)
@@ -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
index 3ac097c9a8c2cd382833b901d0638618e9aaf183..3022fe96f7772e9acb722b0addb61fe26f3a57a3 100644 (file)
@@ -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
index a9e122aeaa7d60dc761000ba09f9a5b3b88af183..0170f0cc76e7d0cab97782418e79172e39b2095e 100644 (file)
@@ -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
index d878f5e7a7258e3f6d12f7df0c6987df04d15ded..2ddffcf79b679625e69f866858fb5ec67c33090d 100644 (file)
@@ -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
index 967f8aea3f44ddf14b176838a70660284c0de028..9d4268b13a286f3e9a8f7ee47cd0e9b3c5879037 100644 (file)
@@ -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
index 5953af58bfcc37bbc5035a90dabeceabf501e96b..30290f14b7385b5e8a1c0478b0fdda0cd284b614 100644 (file)
@@ -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
index 09b5baacd5c984e28302cd3415e5679144802ecc..53665fc9217d31572255f9bbcc229ce4f1bf9ca0 100644 (file)
@@ -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
index 804c0074d351c6b9d5c4cb95117f460e6506ad7d..903a48133f80dc1aa9eb113674012739f4e3e8e3 100644 (file)
@@ -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
index 753d87b6059f1c21352b2238933e0fce24b41b2e..c6fe8e6d1a99ed3f6210df093509136a25105d66 100644 (file)
@@ -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
index 93ebc8a367da4e078417110722bfe68d77dc5b93..a8d619cd18ed6dffa7a9d8adc617b3471ebfa271 100644 (file)
@@ -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
index fdd8d79c8b63298998b8813ce7a97927def64fe0..df23ff01b474b8236920631707305de05060e2e2 100644 (file)
@@ -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
index 219251a77e42c479ddb51aaded25763b51fbf568..20e767eea1f72b2abc52ee82e9877e6164812a80 100644 (file)
@@ -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
index 41356ceba232669daf0e2107c1e573c78c2cf7b0..288ec4db6e1949368e82631e5a09b08673d3813b 100644 (file)
@@ -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
index 3382de41028d6a7d0d03452ebddde44455c8e5cb..402c345887f8d9a7153e551ad7e33e6ba7bb6a85 100644 (file)
@@ -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
index 79132c5548a9267384e0f796689c374ac01a706d..bc020883660d7bafcb5f40c5861715f84850abf8 100644 (file)
@@ -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
index 9661d8faea1581bc54e25cff23d866a964af9574..3d3fd26ece768b912cab3ccee8c35d7677039cb3 100644 (file)
@@ -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
index 20d9b3905c4fb0a9b20d8c8925b457141f9bacec..fcbb16a3bb96f537e02ba4e00244192c7528a1cf 100644 (file)
@@ -1,9 +1,10 @@
-// +build !windows
-
 // Copyright 2019 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !windows
+// +build !windows
+
 package graceful
 
 import (
index 51f29778ba7afbb32bcb459b37eda77972d84afd..e5f5541ed3c3ced09b1a5e0a57c90dc9bd15f188 100644 (file)
@@ -1,10 +1,11 @@
-// +build windows
-
 // Copyright 2019 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
 
+//go:build windows
+// +build windows
+
 package graceful
 
 import (
index 2dc714955e1edba500ef2a0af1d19e8c3c2750b9..6ffa8150cc1a4f599f0447c347043403bb39ed31 100644 (file)
@@ -1,10 +1,11 @@
-// +build !windows
-
 // Copyright 2019 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
 
+//go:build !windows
+// +build !windows
+
 package graceful
 
 import (
index 3fc14334912a00d8169d5a5e105011c4bc77fda6..35b7a9d1feae3d58f1cb38982a3640074211e4ab 100644 (file)
@@ -1,10 +1,11 @@
-// +build windows
-
 // Copyright 2019 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
 
+//go:build windows
+// +build windows
+
 package graceful
 
 import "net"
index 9a94e5fa677bd3ea9efae8ea5d9ac32dbbed7d5c..392ed60cb381b638e768d980675ae799b0807aea 100644 (file)
@@ -1,10 +1,11 @@
-// +build !windows
-
 // Copyright 2019 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler
 
+//go:build !windows
+// +build !windows
+
 package graceful
 
 import (
index abd882990c1375c89fc565555a4a39de7757c735..7e8b812f466dee98e91b798172178a54041be335 100644 (file)
@@ -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 lfs
index b5654d5de751e4f625eb050f1a94e2f806252ca8..d8076b90216f2c67f23ad6a8377358b2ba218352 100644 (file)
@@ -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 lfs
index ffb89df88274bf9cb32a8069d8d7ddfe8df684fe..13fa5d6aa7ebde3a73801e5ed52886798e208851 100644 (file)
@@ -1,9 +1,10 @@
-// +build !bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !bindata
+// +build !bindata
+
 package options
 
 import (
index 262bd0de3e0939d11db2883855250ed55183b5a0..64da772c6fbb33cd5dec1d16667ba8cad786204c 100644 (file)
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
-//+build bindata
+//go:build bindata
+// +build bindata
 
 package options
 
index 5f4ffdda78e49e967ea62068f3b08399ee2bbcac..49e8445cd5950179794754481d5a7540b76e9622 100644 (file)
@@ -1,9 +1,10 @@
-// +build bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build bindata
+// +build bindata
+
 package options
 
 import (
index 0bfe38bc3f3f16a59cdd8c80bb1f199011c69129..955c01e5103134af8fa1da154eb18125aa8087da 100644 (file)
@@ -1,9 +1,10 @@
-// +build !bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !bindata
+// +build !bindata
+
 package public
 
 import (
index 05648aea80939e5ca42921625d5222072e78d464..eb10d96426bf190752517cbf0a68017544297146 100644 (file)
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
-//+build bindata
+//go:build bindata
+// +build bindata
 
 package public
 
index 827dc2a1e0e8d17cbd86ecf364a8fa740b55fb83..6994ed65085741f594a5562bedbaae9dd8520ed6 100644 (file)
@@ -1,9 +1,10 @@
-// +build bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build bindata
+// +build bindata
+
 package public
 
 import (
index 623326ddc2fc11fd7eecb7a005d8d9c98a572040..798292fec86bc42ea83d3189e7b8e08826f38ae0 100644 (file)
@@ -1,3 +1,4 @@
+//go:build sqlite
 // +build sqlite
 
 // Copyright 2014 The Gogs Authors. All rights reserved.
index 1f7af0c9f89d5660c7d46454d910fd563b91e6f1..e11951ff7ec977082ecc84ef3347e0b1731f2131 100644 (file)
@@ -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 bindata
 // +build bindata
 
 package svg
index d667da2d660ca8f42c397af2fa0fde3e91a32aa6..8d857551dc47e51e1de38aa88d35ad5407be72dd 100644 (file)
@@ -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 !bindata
 // +build !bindata
 
 package svg
index 160e4e05f250101ffafeb3ae3fb0c7ea603c37ce..4732fce421fa7d3200193b16014c17fefae1c3ab 100644 (file)
@@ -1,9 +1,10 @@
-// +build !bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !bindata
+// +build !bindata
+
 package templates
 
 import (
index 7f95d77ad3242101f4fd41a371891c0c4b388230..ee20b2af3b3a5132854a555b685a38498c7a1085 100644 (file)
@@ -1,9 +1,10 @@
-// +build bindata
-
 // Copyright 2016 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build bindata
+// +build bindata
+
 package templates
 
 import (
index 5a59286c7a98a3f1a7e75f2dd9e2d4d5254be1ba..887f9eeba25b9b375ebe50ab3a8ad0658877ca8a 100644 (file)
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
-//+build bindata
+//go:build bindata
+// +build bindata
 
 package templates
 
index 3eb38257768a4aa3a07b073cc4b9035dde782b65..e5561b6d72250d239b8adb36c91c20b1c42b33a8 100644 (file)
@@ -771,6 +771,7 @@ use_template = Use this template
 clone_in_vsc = Clone in VS Code
 download_zip = Download ZIP
 download_tar = Download TAR.GZ
+download_bundle = Download BUNDLE
 generate_repo = Generate Repository
 generate_from = Generate From
 repo_desc = Description
index 60ae9b68e82cac711a724402ef216e310789bfb5..1738c06a05fb0bd0b733e9a27f5c9d13799657c2 100644 (file)
@@ -1,9 +1,10 @@
-// +build !windows
-
 // Copyright 2020 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build !windows
+// +build !windows
+
 package private
 
 import (
index f6c9b7ec8ff2520e61acbdccbbcf82cf194896ef..a8a477313fb02d08f8bb62c1585a3ab492dd78b9 100644 (file)
@@ -1,9 +1,10 @@
-// +build windows
-
 // Copyright 2020 The Gitea Authors. All rights reserved.
 // Use of this source code is governed by a MIT-style
 // license that can be found in the LICENSE file.
 
+//go:build windows
+// +build windows
+
 package private
 
 import (
index 00c02813068149339e957bac8132c40aafcd6082..7ae0a94d7ecacdc2a5f7ea20149bf3599558f89c 100644 (file)
@@ -54,6 +54,9 @@ func NewRequest(repoID int64, repo *git.Repository, uri string) (*ArchiveRequest
        case strings.HasSuffix(uri, ".tar.gz"):
                ext = ".tar.gz"
                r.Type = git.TARGZ
+       case strings.HasSuffix(uri, ".bundle"):
+               ext = ".bundle"
+               r.Type = git.BUNDLE
        default:
                return nil, fmt.Errorf("Unknown format: %s", uri)
        }
@@ -165,13 +168,21 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
                        }
                }()
 
-               err = gitRepo.CreateArchive(
-                       graceful.GetManager().ShutdownContext(),
-                       archiver.Type,
-                       w,
-                       setting.Repository.PrefixArchiveFiles,
-                       archiver.CommitID,
-               )
+               if archiver.Type == git.BUNDLE {
+                       err = gitRepo.CreateBundle(
+                               graceful.GetManager().ShutdownContext(),
+                               archiver.CommitID,
+                               w,
+                       )
+               } else {
+                       err = gitRepo.CreateArchive(
+                               graceful.GetManager().ShutdownContext(),
+                               archiver.Type,
+                               w,
+                               setting.Repository.PrefixArchiveFiles,
+                               archiver.CommitID,
+                       )
+               }
                _ = w.CloseWithError(err)
                done <- err
        }(done, w, archiver, gitRepo)
index 50e3061885f80a585ae953a64f03559debbbef81..d9a0ceae7c45a413987568d71e861a83242737c5 100644 (file)
@@ -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 !windows
 // +build !windows
 
 package auth
index 5629c7ee121fd0e8f696fea6a891bbaaeb9babd6..0c377251fa3f62c1e4f0b78b4b936be904c79a9b 100644 (file)
                                                                </a>
                                                                <a class="item archive-link" data-url="{{$.RepoLink}}/archive/{{EscapePound $.BranchName}}.zip">{{svg "octicon-file-zip"}}&nbsp;{{.i18n.Tr "repo.download_zip"}}</a>
                                                                <a class="item archive-link" data-url="{{$.RepoLink}}/archive/{{EscapePound $.BranchName}}.tar.gz">{{svg "octicon-file-zip"}}&nbsp;{{.i18n.Tr "repo.download_tar"}}</a>
+                                                               <a class="item archive-link" data-url="{{$.RepoLink}}/archive/{{EscapePound $.BranchName}}.bundle">{{svg "octicon-package"}}&nbsp;{{.i18n.Tr "repo.download_bundle"}}</a>
                                                        </div>
                                                </button>
                                        </div>
index ca35ff4f00826bb93b83360451a9661d19d230f6..2f980b3b895fd1e59b795ca0527169e665421ea5 100644 (file)
@@ -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 gofuzz
 // +build gofuzz
 
 package fuzz