Skip to content

Commit 7445215

Browse files
authored
Merge branch 'main' into lunny/fix_branch_total
2 parents 5aaba4d + efaf109 commit 7445215

File tree

84 files changed

+168
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+168
-42
lines changed

build.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5-
//+build vendor
5+
//go:build vendor
6+
// +build vendor
67

78
package main
89

build/generate-bindata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build ignore
56
// +build ignore
67

78
package main

build/generate-emoji.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build ignore
67
// +build ignore
78

89
package main

build/generate-gitignores.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build ignore
12
// +build ignore
23

34
package main

build/generate-licenses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build ignore
12
// +build ignore
23

34
package main

build/gocovmerge.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// gocovmerge takes the results from multiple `go test -coverprofile` runs and
77
// merges them into one profile
88

9+
//go:build ignore
910
// +build ignore
1011

1112
package main

cmd/embedded.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build bindata
56
// +build bindata
67

78
package cmd

cmd/embedded_stub.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !bindata
56
// +build !bindata
67

78
package cmd

models/migrations/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
429429
// Reset the mapper between each migration - migrations are not supposed to depend on each other
430430
x.SetMapper(names.GonicMapper{})
431431
if err = m.Migrate(x); err != nil {
432-
return fmt.Errorf("do migrate: %v", err)
432+
return fmt.Errorf("migration[%d]: %s failed: %v", v+int64(i), m.Description(), err)
433433
}
434434
currentVersion.Version = v + int64(i) + 1
435435
if _, err = x.ID(1).Update(currentVersion); err != nil {

modules/auth/pam/pam.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// +build pam
2-
31
// Copyright 2014 The Gogs Authors. All rights reserved.
42
// Use of this source code is governed by a MIT-style
53
// license that can be found in the LICENSE file.
64

5+
//go:build pam
6+
// +build pam
7+
78
package pam
89

910
import (

modules/auth/pam/pam_stub.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
// +build !pam
2-
31
// Copyright 2014 The Gogs Authors. All rights reserved.
42
// Use of this source code is governed by a MIT-style
53
// license that can be found in the LICENSE file.
64

5+
//go:build !pam
6+
// +build !pam
7+
78
package pam
89

910
import (

modules/auth/pam/pam_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build pam
12
// +build pam
23

34
// Copyright 2021 The Gitea Authors. All rights reserved.

modules/git/blob_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/blob_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/command_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build race
56
// +build race
67

78
package git

modules/git/commit_convert_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/commit_info_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/commit_info_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/last_commit_cache_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/last_commit_cache_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/notes_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/notes_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/parse_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/parse_gogit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/parse_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/parse_nogogit_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/pipeline/lfs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package pipeline

modules/git/pipeline/lfs_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package pipeline

modules/git/repo.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"net/url"
1414
"os"
1515
"path"
16+
"path/filepath"
1617
"strconv"
1718
"strings"
1819
"time"
@@ -415,3 +416,33 @@ func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string
415416

416417
return DivergeObject{ahead, behind}, nil
417418
}
419+
420+
// CreateBundle create bundle content to the target path
421+
func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.Writer) error {
422+
tmp, err := os.MkdirTemp(os.TempDir(), "gitea-bundle")
423+
if err != nil {
424+
return err
425+
}
426+
defer os.RemoveAll(tmp)
427+
428+
tmpFile := filepath.Join(tmp, "bundle")
429+
args := []string{
430+
"bundle",
431+
"create",
432+
tmpFile,
433+
commit,
434+
}
435+
_, err = NewCommandContext(ctx, args...).RunInDir(repo.Path)
436+
if err != nil {
437+
return err
438+
}
439+
440+
fi, err := os.Open(tmpFile)
441+
if err != nil {
442+
return err
443+
}
444+
defer fi.Close()
445+
446+
_, err = io.Copy(out, fi)
447+
return err
448+
}

modules/git/repo_archive.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121
ZIP ArchiveType = iota + 1
2222
// TARGZ tar gz archive type
2323
TARGZ
24+
// BUNDLE bundle archive type
25+
BUNDLE
2426
)
2527

2628
// String converts an ArchiveType to string
@@ -30,6 +32,8 @@ func (a ArchiveType) String() string {
3032
return "zip"
3133
case TARGZ:
3234
return "tar.gz"
35+
case BUNDLE:
36+
return "bundle"
3337
}
3438
return "unknown"
3539
}

modules/git/repo_base_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/repo_base_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build !gogit
67
// +build !gogit
78

89
package git

modules/git/repo_blob_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/repo_blob_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/repo_branch_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/repo_branch_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build !gogit
67
// +build !gogit
78

89
package git

modules/git/repo_commit_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/repo_commit_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/repo_commitgraph_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

modules/git/repo_language_stats_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/repo_language_stats_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/repo_ref_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build gogit
56
// +build gogit
67

78
package git

modules/git/repo_ref_nogogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !gogit
56
// +build !gogit
67

78
package git

modules/git/repo_tag_gogit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Use of this source code is governed by a MIT-style
44
// license that can be found in the LICENSE file.
55

6+
//go:build gogit
67
// +build gogit
78

89
package git

0 commit comments

Comments
 (0)