Skip to content

Commit 2e3de0e

Browse files
authored
Merge branch 'main' into raw-text-mime-type-mapping
2 parents d471cd6 + 9979983 commit 2e3de0e

Some content is hidden

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

41 files changed

+643
-58
lines changed

cmd/serv.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
package cmd
77

88
import (
9+
"context"
910
"fmt"
1011
"net/http"
1112
"net/url"
1213
"os"
1314
"os/exec"
15+
"os/signal"
1416
"regexp"
1517
"strconv"
1618
"strings"
19+
"syscall"
1720
"time"
1821

1922
"code.gitea.io/gitea/models"
@@ -273,12 +276,31 @@ func runServ(c *cli.Context) error {
273276
verb = strings.Replace(verb, "-", " ", 1)
274277
}
275278

279+
ctx, cancel := context.WithCancel(context.Background())
280+
defer cancel()
281+
go func() {
282+
// install notify
283+
signalChannel := make(chan os.Signal, 1)
284+
285+
signal.Notify(
286+
signalChannel,
287+
syscall.SIGINT,
288+
syscall.SIGTERM,
289+
)
290+
select {
291+
case <-signalChannel:
292+
case <-ctx.Done():
293+
}
294+
cancel()
295+
signal.Reset()
296+
}()
297+
276298
var gitcmd *exec.Cmd
277299
verbs := strings.Split(verb, " ")
278300
if len(verbs) == 2 {
279-
gitcmd = exec.Command(verbs[0], verbs[1], repoPath)
301+
gitcmd = exec.CommandContext(ctx, verbs[0], verbs[1], repoPath)
280302
} else {
281-
gitcmd = exec.Command(verb, repoPath)
303+
gitcmd = exec.CommandContext(ctx, verb, repoPath)
282304
}
283305

284306
gitcmd.Dir = setting.RepoRootPath

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,9 @@ PATH =
573573
;;
574574
;; Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
575575
;PULL_REQUEST_PUSH_MESSAGE = true
576+
;;
577+
;; (Go-Git only) Don't cache objects greater than this in memory. (Set to 0 to disable.)
578+
;LARGE_OBJECT_THRESHOLD = 1048576
576579

577580
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
578581
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ params:
1818
description: Git with a cup of tea
1919
author: The Gitea Authors
2020
website: https://docs.gitea.io
21-
version: 1.14.2
21+
version: 1.14.3
2222
minGoVersion: 1.14
2323
goVersion: 1.16
2424
minNodeVersion: 12.17

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
837837
- `PULL_REQUEST_PUSH_MESSAGE`: **true**: Respond to pushes to a non-default branch with a URL for creating a Pull Request (if the repository has them enabled)
838838
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
839839
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
840-
840+
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
841841
## Git - Timeout settings (`git.timeout`)
842842
- `DEFAUlT`: **360**: Git operations default timeout seconds.
843843
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ require (
4141
github.com/go-chi/cors v1.2.0
4242
github.com/go-enry/go-enry/v2 v2.7.0
4343
github.com/go-git/go-billy/v5 v5.3.1
44-
github.com/go-git/go-git/v5 v5.4.2
44+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4
4545
github.com/go-ldap/ldap/v3 v3.3.0
4646
github.com/go-redis/redis/v8 v8.10.0
4747
github.com/go-sql-driver/mysql v1.6.0
@@ -123,9 +123,9 @@ require (
123123
go.uber.org/multierr v1.7.0 // indirect
124124
go.uber.org/zap v1.17.0 // indirect
125125
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
126-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
126+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
127127
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
128-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
128+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
129129
golang.org/x/text v0.3.6
130130
golang.org/x/time v0.0.0-20210608053304-ed9ce3a009e4 // indirect
131131
golang.org/x/tools v0.1.0

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Ai
313313
github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
314314
github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
315315
github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
316-
github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
317-
github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
316+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4 h1:1RSUwVK7VjTeA82kcLIqz1EU70QRwFdZUlJW58gP4GY=
317+
github.com/go-git/go-git/v5 v5.4.3-0.20210630082519-b4368b2a2ca4/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
318318
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
319319
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
320320
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -1233,8 +1233,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
12331233
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
12341234
golang.org/x/net v0.0.0-20210331060903-cb1fcc7394e5/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
12351235
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
1236-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
1237-
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
1236+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
1237+
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
12381238
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12391239
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
12401240
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1339,8 +1339,9 @@ golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7w
13391339
golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13401340
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13411341
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1342-
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
13431342
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1343+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
1344+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13441345
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
13451346
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
13461347
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

models/user_mail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ type SearchEmailResult struct {
316316
// SearchEmails takes options i.e. keyword and part of email name to search,
317317
// it returns results in given range and number of total results.
318318
func SearchEmails(opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error) {
319-
var cond builder.Cond = builder.Eq{"user.`type`": UserTypeIndividual}
319+
var cond builder.Cond = builder.Eq{"`user`.`type`": UserTypeIndividual}
320320
if len(opts.Keyword) > 0 {
321321
likeStr := "%" + strings.ToLower(opts.Keyword) + "%"
322322
cond = cond.And(builder.Or(

modules/git/repo_base_gogit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"path/filepath"
1313

1414
gitealog "code.gitea.io/gitea/modules/log"
15+
"code.gitea.io/gitea/modules/setting"
16+
1517
"github.com/go-git/go-billy/v5/osfs"
1618
gogit "github.com/go-git/go-git/v5"
1719
"github.com/go-git/go-git/v5/plumbing/cache"
@@ -46,7 +48,7 @@ func OpenRepository(repoPath string) (*Repository, error) {
4648
return nil, err
4749
}
4850
}
49-
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true})
51+
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold})
5052
gogitRepo, err := gogit.Open(storage, fs)
5153
if err != nil {
5254
return nil, err

modules/git/repo_commit.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,15 @@ func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (in
264264
return len(strings.Split(stdout, "\n")) - 1, nil
265265
}
266266

267-
// CommitsBetween returns a list that contains commits between [last, before).
267+
// CommitsBetween returns a list that contains commits between [before, last).
268+
// If before is detached (removed by reset + push) it is not included.
268269
func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) {
269270
var stdout []byte
270271
var err error
271272
if before == nil {
272273
stdout, err = NewCommand("rev-list", last.ID.String()).RunInDirBytes(repo.Path)
273274
} else {
274-
stdout, err = NewCommand("rev-list", before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
275+
stdout, err = NewCommand("rev-list", before.ID.String()+".."+last.ID.String()).RunInDirBytes(repo.Path)
275276
if err != nil && strings.Contains(err.Error(), "no merge base") {
276277
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
277278
// previously it would return the results of git rev-list before last so let's try that...
@@ -284,14 +285,14 @@ func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List
284285
return repo.parsePrettyFormatLogToList(bytes.TrimSpace(stdout))
285286
}
286287

287-
// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [last, before)
288+
// CommitsBetweenLimit returns a list that contains at most limit commits skipping the first skip commits between [before, last)
288289
func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) (*list.List, error) {
289290
var stdout []byte
290291
var err error
291292
if before == nil {
292293
stdout, err = NewCommand("rev-list", "--max-count", strconv.Itoa(limit), "--skip", strconv.Itoa(skip), last.ID.String()).RunInDirBytes(repo.Path)
293294
} else {
294-
stdout, err = NewCommand("rev-list", "--max-count", strconv.Itoa(limit), "--skip", strconv.Itoa(skip), before.ID.String()+"..."+last.ID.String()).RunInDirBytes(repo.Path)
295+
stdout, err = NewCommand("rev-list", "--max-count", strconv.Itoa(limit), "--skip", strconv.Itoa(skip), before.ID.String()+".."+last.ID.String()).RunInDirBytes(repo.Path)
295296
if err != nil && strings.Contains(err.Error(), "no merge base") {
296297
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
297298
// previously it would return the results of git rev-list --max-count n before last so let's try that...
@@ -322,7 +323,7 @@ func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, erro
322323

323324
// CommitsCountBetween return numbers of commits between two commits
324325
func (repo *Repository) CommitsCountBetween(start, end string) (int64, error) {
325-
count, err := CommitsCountFiles(repo.Path, []string{start + "..." + end}, []string{})
326+
count, err := CommitsCountFiles(repo.Path, []string{start + ".." + end}, []string{})
326327
if err != nil && strings.Contains(err.Error(), "no merge base") {
327328
// future versions of git >= 2.28 are likely to return an error if before and last have become unrelated.
328329
// previously it would return the results of git rev-list before last so let's try that...

modules/git/repo_commit_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,25 @@ func TestIsCommitInBranch(t *testing.T) {
7878
assert.NoError(t, err)
7979
assert.False(t, result)
8080
}
81+
82+
func TestRepository_CommitsBetweenIDs(t *testing.T) {
83+
bareRepo1Path := filepath.Join(testReposDir, "repo4_commitsbetween")
84+
bareRepo1, err := OpenRepository(bareRepo1Path)
85+
assert.NoError(t, err)
86+
defer bareRepo1.Close()
87+
88+
cases := []struct {
89+
OldID string
90+
NewID string
91+
ExpectedCommits int
92+
}{
93+
{"fdc1b615bdcff0f0658b216df0c9209e5ecb7c78", "78a445db1eac62fe15e624e1137965969addf344", 1}, //com1 -> com2
94+
{"78a445db1eac62fe15e624e1137965969addf344", "fdc1b615bdcff0f0658b216df0c9209e5ecb7c78", 0}, //reset HEAD~, com2 -> com1
95+
{"78a445db1eac62fe15e624e1137965969addf344", "a78e5638b66ccfe7e1b4689d3d5684e42c97d7ca", 1}, //com2 -> com2_new
96+
}
97+
for i, c := range cases {
98+
commits, err := bareRepo1.CommitsBetweenIDs(c.NewID, c.OldID)
99+
assert.NoError(t, err)
100+
assert.Equal(t, c.ExpectedCommits, commits.Len(), "case %d", i)
101+
}
102+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/main
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = false
4+
bare = false
5+
logallrefupdates = true
6+
symlinks = false
7+
ignorecase = true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0000000000000000000000000000000000000000 fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 KN4CK3R <[email protected]> 1624915979 +0200 commit (initial): com1
2+
fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 78a445db1eac62fe15e624e1137965969addf344 KN4CK3R <[email protected]> 1624915993 +0200 commit: com2
3+
78a445db1eac62fe15e624e1137965969addf344 fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 KN4CK3R <[email protected]> 1624916008 +0200 reset: moving to HEAD~1
4+
fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 a78e5638b66ccfe7e1b4689d3d5684e42c97d7ca KN4CK3R <[email protected]> 1624916029 +0200 commit: com2_new
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0000000000000000000000000000000000000000 fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 KN4CK3R <[email protected]> 1624915979 +0200 commit (initial): com1
2+
fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 78a445db1eac62fe15e624e1137965969addf344 KN4CK3R <[email protected]> 1624915993 +0200 commit: com2
3+
78a445db1eac62fe15e624e1137965969addf344 fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 KN4CK3R <[email protected]> 1624916008 +0200 reset: moving to HEAD~1
4+
fdc1b615bdcff0f0658b216df0c9209e5ecb7c78 a78e5638b66ccfe7e1b4689d3d5684e42c97d7ca KN4CK3R <[email protected]> 1624916029 +0200 commit: com2_new
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x��M
2+
�0@a�=E��̤I������$�Zl�����|�G���)�îm̊uO�"����&`�8Gt�I�7�#n�6%�09�)�8�F�(hl��@���MuS��\����1�y=�%?i�u�"��O
3+
��Dm�ڃ��w���ź{p�C_
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a78e5638b66ccfe7e1b4689d3d5684e42c97d7ca

modules/markup/external/external.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package external
66

77
import (
8+
"context"
89
"fmt"
910
"io"
1011
"io/ioutil"
@@ -15,6 +16,7 @@ import (
1516

1617
"code.gitea.io/gitea/modules/log"
1718
"code.gitea.io/gitea/modules/markup"
19+
"code.gitea.io/gitea/modules/process"
1820
"code.gitea.io/gitea/modules/setting"
1921
"code.gitea.io/gitea/modules/util"
2022
)
@@ -96,7 +98,13 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
9698
args = append(args, f.Name())
9799
}
98100

99-
cmd := exec.Command(commands[0], args...)
101+
processCtx, cancel := context.WithCancel(ctx.Ctx)
102+
defer cancel()
103+
104+
pid := process.GetManager().Add(fmt.Sprintf("Render [%s] for %s", commands[0], ctx.URLPrefix), cancel)
105+
defer process.GetManager().Remove(pid)
106+
107+
cmd := exec.CommandContext(processCtx, commands[0], args...)
100108
cmd.Env = append(
101109
os.Environ(),
102110
"GITEA_PREFIX_SRC="+ctx.URLPrefix,

modules/setting/git.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var (
2525
GCArgs []string `ini:"GC_ARGS" delim:" "`
2626
EnableAutoGitWireProtocol bool
2727
PullRequestPushMessage bool
28+
LargeObjectThreshold int64
2829
Timeout struct {
2930
Default int
3031
Migrate int
@@ -45,6 +46,7 @@ var (
4546
GCArgs: []string{},
4647
EnableAutoGitWireProtocol: true,
4748
PullRequestPushMessage: true,
49+
LargeObjectThreshold: 1024 * 1024,
4850
Timeout: struct {
4951
Default int
5052
Migrate int

modules/ssh/ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func sessionHandler(session ssh.Session) {
6666

6767
args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
6868
log.Trace("SSH: Arguments: %v", args)
69-
cmd := exec.Command(setting.AppPath, args...)
69+
cmd := exec.CommandContext(session.Context(), setting.AppPath, args...)
7070
cmd.Env = append(
7171
os.Environ(),
7272
"SSH_ORIGINAL_COMMAND="+command,

routers/web/repo/view.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"code.gitea.io/gitea/modules/log"
3030
"code.gitea.io/gitea/modules/markup"
3131
"code.gitea.io/gitea/modules/setting"
32+
"code.gitea.io/gitea/modules/structs"
3233
"code.gitea.io/gitea/modules/typesniffer"
3334
)
3435

@@ -624,6 +625,7 @@ func Home(ctx *context.Context) {
624625
ctx.Data["Repo"] = ctx.Repo
625626
ctx.Data["MigrateTask"] = task
626627
ctx.Data["CloneAddr"] = safeURL(cfg.CloneAddr)
628+
ctx.Data["Failed"] = task.Status == structs.TaskStatusFailed
627629
ctx.HTML(http.StatusOK, tplMigrating)
628630
return
629631
}

templates/repo/empty.tmpl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ git init
3333
{{if ne .Repository.DefaultBranch "master"}}git checkout -b {{.Repository.DefaultBranch}}{{end}}
3434
git add README.md
3535
git commit -m "first commit"
36-
git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
36+
git remote add origin <span class="clone-url">{{$.CloneLink.HTTPS}}</span>
3737
git push -u origin {{.Repository.DefaultBranch}}</code></pre>
3838
</div>
3939
</div>
@@ -42,10 +42,19 @@ git push -u origin {{.Repository.DefaultBranch}}</code></pre>
4242
<div class="item">
4343
<h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
4444
<div class="markup">
45-
<pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
45+
<pre><code>git remote add origin <span class="clone-url">{{$.CloneLink.HTTPS}}</span>
4646
git push -u origin {{.Repository.DefaultBranch}}</code></pre>
4747
</div>
4848
</div>
49+
<script defer>
50+
/* eslint-disable no-undef */
51+
const cloneUrls = document.getElementsByClassName('clone-url');
52+
if (cloneUrls) {
53+
for (let i = 0; i < cloneUrls.length; i++) {
54+
cloneUrls[i].textContent = (isSSH ? sshButton : httpsButton).dataset.link;
55+
}
56+
}
57+
</script>
4958
{{end}}
5059
{{else}}
5160
<div class="ui segment center">

0 commit comments

Comments
 (0)