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>
pull/16803/head^2
John Olheiser 3 years ago committed by GitHub
parent d22cb600ed
commit 648464b504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      build.go
  2. 1
      build/generate-bindata.go
  3. 1
      build/generate-emoji.go
  4. 1
      build/generate-gitignores.go
  5. 1
      build/generate-licenses.go
  6. 1
      build/gocovmerge.go
  7. 1
      cmd/embedded.go
  8. 1
      cmd/embedded_stub.go
  9. 5
      modules/auth/pam/pam.go
  10. 5
      modules/auth/pam/pam_stub.go
  11. 1
      modules/auth/pam/pam_test.go
  12. 1
      modules/git/blob_gogit.go
  13. 1
      modules/git/blob_nogogit.go
  14. 1
      modules/git/command_test.go
  15. 1
      modules/git/commit_convert_gogit.go
  16. 1
      modules/git/commit_info_gogit.go
  17. 1
      modules/git/commit_info_nogogit.go
  18. 1
      modules/git/last_commit_cache_gogit.go
  19. 1
      modules/git/last_commit_cache_nogogit.go
  20. 1
      modules/git/notes_gogit.go
  21. 1
      modules/git/notes_nogogit.go
  22. 1
      modules/git/parse_gogit.go
  23. 1
      modules/git/parse_gogit_test.go
  24. 1
      modules/git/parse_nogogit.go
  25. 1
      modules/git/parse_nogogit_test.go
  26. 1
      modules/git/pipeline/lfs.go
  27. 1
      modules/git/pipeline/lfs_nogogit.go
  28. 31
      modules/git/repo.go
  29. 4
      modules/git/repo_archive.go
  30. 1
      modules/git/repo_base_gogit.go
  31. 1
      modules/git/repo_base_nogogit.go
  32. 1
      modules/git/repo_blob_gogit.go
  33. 1
      modules/git/repo_blob_nogogit.go
  34. 1
      modules/git/repo_branch_gogit.go
  35. 1
      modules/git/repo_branch_nogogit.go
  36. 1
      modules/git/repo_commit_gogit.go
  37. 1
      modules/git/repo_commit_nogogit.go
  38. 1
      modules/git/repo_commitgraph_gogit.go
  39. 1
      modules/git/repo_language_stats_gogit.go
  40. 1
      modules/git/repo_language_stats_nogogit.go
  41. 1
      modules/git/repo_ref_gogit.go
  42. 1
      modules/git/repo_ref_nogogit.go
  43. 1
      modules/git/repo_tag_gogit.go
  44. 1
      modules/git/repo_tag_nogogit.go
  45. 1
      modules/git/repo_tree_gogit.go
  46. 1
      modules/git/repo_tree_nogogit.go
  47. 1
      modules/git/sha1_gogit.go
  48. 1
      modules/git/sha1_nogogit.go
  49. 1
      modules/git/signature_gogit.go
  50. 1
      modules/git/signature_nogogit.go
  51. 1
      modules/git/tree_blob_gogit.go
  52. 1
      modules/git/tree_blob_nogogit.go
  53. 1
      modules/git/tree_entry_gogit.go
  54. 1
      modules/git/tree_entry_nogogit.go
  55. 1
      modules/git/tree_entry_test.go
  56. 1
      modules/git/tree_gogit.go
  57. 1
      modules/git/tree_nogogit.go
  58. 5
      modules/graceful/manager_unix.go
  59. 5
      modules/graceful/manager_windows.go
  60. 5
      modules/graceful/net_unix.go
  61. 5
      modules/graceful/net_windows.go
  62. 5
      modules/graceful/restart_unix.go
  63. 1
      modules/lfs/pointer_scanner_gogit.go
  64. 1
      modules/lfs/pointer_scanner_nogogit.go
  65. 5
      modules/options/dynamic.go
  66. 1
      modules/options/options_bindata.go
  67. 5
      modules/options/static.go
  68. 5
      modules/public/dynamic.go
  69. 1
      modules/public/public_bindata.go
  70. 5
      modules/public/static.go
  71. 1
      modules/setting/database_sqlite.go
  72. 1
      modules/svg/discover_bindata.go
  73. 1
      modules/svg/discover_nobindata.go
  74. 5
      modules/templates/dynamic.go
  75. 5
      modules/templates/static.go
  76. 1
      modules/templates/templates_bindata.go
  77. 1
      options/locale/locale_en-US.ini
  78. 5
      routers/private/manager_unix.go
  79. 5
      routers/private/manager_windows.go
  80. 11
      services/archiver/archiver.go
  81. 1
      services/auth/placeholder.go
  82. 1
      templates/repo/home.tmpl
  83. 1
      tools/fuzz.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 vendor
// +build vendor
package main

@ -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

@ -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

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore
package main

@ -1,3 +1,4 @@
//go:build ignore
// +build ignore
package main

@ -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

@ -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

@ -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

@ -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 (

@ -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 (

@ -1,3 +1,4 @@
//go:build pam
// +build pam
// Copyright 2021 The Gitea Authors. All rights reserved.

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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
}

@ -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"
}

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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 (

@ -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 (

@ -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 (

@ -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"

@ -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 (

@ -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

@ -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

@ -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 (

@ -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 options

@ -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 (

@ -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 (

@ -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 public

@ -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 (

@ -1,3 +1,4 @@
//go:build sqlite
// +build sqlite
// Copyright 2014 The Gogs Authors. All rights reserved.

@ -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

@ -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

@ -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 (

@ -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 (

@ -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 templates

@ -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

@ -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 (

@ -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 (

@ -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,6 +168,13 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
}
}()
if archiver.Type == git.BUNDLE {
err = gitRepo.CreateBundle(
graceful.GetManager().ShutdownContext(),
archiver.CommitID,
w,
)
} else {
err = gitRepo.CreateArchive(
graceful.GetManager().ShutdownContext(),
archiver.Type,
@ -172,6 +182,7 @@ func doArchive(r *ArchiveRequest) (*models.RepoArchiver, error) {
setting.Repository.PrefixArchiveFiles,
archiver.CommitID,
)
}
_ = w.CloseWithError(err)
done <- err
}(done, w, archiver, gitRepo)

@ -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

@ -118,6 +118,7 @@
</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>

@ -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

Loading…
Cancel
Save