Skip to content

Commit 0486de0

Browse files
authored
Merge branch 'main' into lunny/rename_pr_headrefname
2 parents 2b1698d + bc78a9a commit 0486de0

File tree

46 files changed

+100
-75
lines changed

Some content is hidden

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

46 files changed

+100
-75
lines changed

models/issues/issue_xref.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (issue *Issue) verifyReferencedIssue(stdCtx context.Context, ctx *crossRefe
235235

236236
// AddCrossReferences add cross references
237237
func (c *Comment) AddCrossReferences(stdCtx context.Context, doer *user_model.User, removeOld bool) error {
238-
if c.Type != CommentTypeCode && c.Type != CommentTypeComment {
238+
if !c.Type.HasContentSupport() {
239239
return nil
240240
}
241241
if err := c.LoadIssue(stdCtx); err != nil {

modules/actions/artifacts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func IsArtifactV4(art *actions_model.ActionArtifact) bool {
2020

2121
func DownloadArtifactV4ServeDirectOnly(ctx *context.Base, art *actions_model.ActionArtifact) (bool, error) {
2222
if setting.Actions.ArtifactStorage.ServeDirect() {
23-
u, err := storage.ActionsArtifacts.URL(art.StoragePath, art.ArtifactPath, nil)
23+
u, err := storage.ActionsArtifacts.URL(art.StoragePath, art.ArtifactPath, ctx.Req.Method, nil)
2424
if u != nil && err == nil {
2525
ctx.Redirect(u.String(), http.StatusFound)
2626
return true, nil

modules/git/commit_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type CommitInfo struct {
1515
func getCommitInfoSubmoduleFile(repoLink string, entry *TreeEntry, commit *Commit, treePathDir string) (*CommitSubmoduleFile, error) {
1616
fullPath := path.Join(treePathDir, entry.Name())
1717
submodule, err := commit.GetSubModule(fullPath)
18-
if err != nil {
18+
if submodule == nil || err != nil {
1919
return nil, err
2020
}
2121
return NewCommitSubmoduleFile(repoLink, fullPath, submodule.URL, entry.ID.String()), nil

modules/git/commit_info_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
const (
@@ -120,6 +121,16 @@ func TestEntries_GetCommitsInfo(t *testing.T) {
120121
defer clonedRepo1.Close()
121122

122123
testGetCommitsInfo(t, clonedRepo1)
124+
125+
t.Run("NonExistingSubmoduleAsNil", func(t *testing.T) {
126+
commit, err := bareRepo1.GetCommit("HEAD")
127+
require.NoError(t, err)
128+
tree, err := commit.GetTreeEntryByPath("file1.txt")
129+
require.NoError(t, err)
130+
cisf, err := getCommitInfoSubmoduleFile("/any/repo-link", tree, commit, "")
131+
require.NoError(t, err)
132+
assert.Nil(t, cisf)
133+
})
123134
}
124135

125136
func BenchmarkEntries_GetCommitsInfo(b *testing.B) {

modules/git/commit_submodule.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func (c *Commit) GetSubModules() (*ObjectCache[*SubModule], error) {
3535
return c.submoduleCache, nil
3636
}
3737

38-
// GetSubModule get the submodule according entry name
38+
// GetSubModule gets the submodule by the entry name.
39+
// It returns "nil, nil" if the submodule does not exist, caller should always remember to check the "nil"
3940
func (c *Commit) GetSubModule(entryName string) (*SubModule, error) {
4041
modules, err := c.GetSubModules()
4142
if err != nil {

modules/packages/content_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func (s *ContentStore) ShouldServeDirect() bool {
3636
return setting.Packages.Storage.ServeDirect()
3737
}
3838

39-
func (s *ContentStore) GetServeDirectURL(key BlobHash256Key, filename string, reqParams url.Values) (*url.URL, error) {
40-
return s.store.URL(KeyToRelativePath(key), filename, reqParams)
39+
func (s *ContentStore) GetServeDirectURL(key BlobHash256Key, filename, method string, reqParams url.Values) (*url.URL, error) {
40+
return s.store.URL(KeyToRelativePath(key), filename, method, reqParams)
4141
}
4242

4343
// FIXME: Workaround to be removed in v1.20

modules/storage/azureblob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func (a *AzureBlobStorage) Delete(path string) error {
247247
}
248248

249249
// URL gets the redirect URL to a file. The presigned link is valid for 5 minutes.
250-
func (a *AzureBlobStorage) URL(path, name string, reqParams url.Values) (*url.URL, error) {
250+
func (a *AzureBlobStorage) URL(path, name, _ string, reqParams url.Values) (*url.URL, error) {
251251
blobClient := a.getBlobClient(path)
252252

253253
startTime := time.Now()

modules/storage/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (s discardStorage) Delete(_ string) error {
3030
return fmt.Errorf("%s", s)
3131
}
3232

33-
func (s discardStorage) URL(_, _ string, _ url.Values) (*url.URL, error) {
33+
func (s discardStorage) URL(_, _, _ string, _ url.Values) (*url.URL, error) {
3434
return nil, fmt.Errorf("%s", s)
3535
}
3636

modules/storage/helper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func Test_discardStorage(t *testing.T) {
3737
assert.Error(t, err, string(tt))
3838
}
3939
{
40-
got, err := tt.URL("path", "name", nil)
40+
got, err := tt.URL("path", "name", "GET", nil)
4141
assert.Nil(t, got)
4242
assert.Errorf(t, err, string(tt))
4343
}

modules/storage/local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (l *LocalStorage) Delete(path string) error {
114114
}
115115

116116
// URL gets the redirect URL to a file
117-
func (l *LocalStorage) URL(path, name string, reqParams url.Values) (*url.URL, error) {
117+
func (l *LocalStorage) URL(path, name, _ string, reqParams url.Values) (*url.URL, error) {
118118
return nil, ErrURLNotSupported
119119
}
120120

0 commit comments

Comments
 (0)