Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63a3a81

Browse files
authored
Merge branch 'main' into logout_redirect_main
2 parents8d868ac +69700f9 commit63a3a81

File tree

46 files changed

+976
-871
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

+976
-871
lines changed

‎models/perm/access/repo_permission.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,14 @@ func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Reposito
276276
if!actionsCfg.IsCollaborativeOwner(taskRepo.OwnerID)||!taskRepo.IsPrivate {
277277
// The task repo can access the current repo only if the task repo is private and
278278
// the owner of the task repo is a collaborative owner of the current repo.
279-
// FIXME allow public repo read access if tokenless pull is enabled
280279
// FIXME should owner's visibility also be considered here?
280+
281+
// check permission like simple user but limit to read-only
282+
perm,err=GetUserRepoPermission(ctx,repo,user_model.NewActionsUser())
283+
iferr!=nil {
284+
returnperm,err
285+
}
286+
perm.AccessMode=min(perm.AccessMode,perm_model.AccessModeRead)
281287
returnperm,nil
282288
}
283289
accessMode=perm_model.AccessModeRead

‎modules/fileicon/material.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (m *MaterialIconProvider) renderFileIconSVG(p *RenderedIconPool, name, svg,
7676
ifp.IconSVGs[svgID]=="" {
7777
p.IconSVGs[svgID]=svgHTML
7878
}
79-
returntemplate.HTML(`<svg `+svgCommonAttrs+`><usexlink:href="#`+svgID+`"></use></svg>`)
79+
returntemplate.HTML(`<svg `+svgCommonAttrs+`><use href="#`+svgID+`"></use></svg>`)
8080
}
8181

8282
func (m*MaterialIconProvider)EntryIconHTML(p*RenderedIconPool,entry*EntryInfo) template.HTML {

‎modules/fileicon/render.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (p *RenderedIconPool) RenderToHTML() template.HTML {
2525
return""
2626
}
2727
sb:=&strings.Builder{}
28-
sb.WriteString(`<div class=tw-hidden>`)
28+
sb.WriteString(`<div class="svg-icon-container">`)
2929
for_,icon:=rangep.IconSVGs {
3030
sb.WriteString(string(icon))
3131
}

‎modules/git/commit.go‎

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
package git
66

77
import (
8-
"bufio"
9-
"bytes"
108
"context"
119
"errors"
1210
"io"
1311
"os/exec"
14-
"strconv"
1512
"strings"
1613

1714
"code.gitea.io/gitea/modules/git/gitcmd"
18-
"code.gitea.io/gitea/modules/log"
1915
"code.gitea.io/gitea/modules/util"
2016
)
2117

@@ -130,65 +126,6 @@ func CommitChanges(ctx context.Context, repoPath string, opts CommitChangesOptio
130126
returnerr
131127
}
132128

133-
// AllCommitsCount returns count of all commits in repository
134-
funcAllCommitsCount(ctx context.Context,repoPathstring,hidePRRefsbool,files...string) (int64,error) {
135-
cmd:=gitcmd.NewCommand("rev-list")
136-
ifhidePRRefs {
137-
cmd.AddArguments("--exclude="+PullPrefix+"*")
138-
}
139-
cmd.AddArguments("--all","--count")
140-
iflen(files)>0 {
141-
cmd.AddDashesAndList(files...)
142-
}
143-
144-
stdout,_,err:=cmd.WithDir(repoPath).RunStdString(ctx)
145-
iferr!=nil {
146-
return0,err
147-
}
148-
149-
returnstrconv.ParseInt(strings.TrimSpace(stdout),10,64)
150-
}
151-
152-
// CommitsCountOptions the options when counting commits
153-
typeCommitsCountOptionsstruct {
154-
RepoPathstring
155-
Notstring
156-
Revision []string
157-
RelPath []string
158-
Sincestring
159-
Untilstring
160-
}
161-
162-
// CommitsCount returns number of total commits of until given revision.
163-
funcCommitsCount(ctx context.Context,optsCommitsCountOptions) (int64,error) {
164-
cmd:=gitcmd.NewCommand("rev-list","--count")
165-
166-
cmd.AddDynamicArguments(opts.Revision...)
167-
168-
ifopts.Not!="" {
169-
cmd.AddOptionValues("--not",opts.Not)
170-
}
171-
172-
iflen(opts.RelPath)>0 {
173-
cmd.AddDashesAndList(opts.RelPath...)
174-
}
175-
176-
stdout,_,err:=cmd.WithDir(opts.RepoPath).RunStdString(ctx)
177-
iferr!=nil {
178-
return0,err
179-
}
180-
181-
returnstrconv.ParseInt(strings.TrimSpace(stdout),10,64)
182-
}
183-
184-
// CommitsCount returns number of total commits of until current revision.
185-
func (c*Commit)CommitsCount() (int64,error) {
186-
returnCommitsCount(c.repo.Ctx,CommitsCountOptions{
187-
RepoPath:c.repo.Path,
188-
Revision: []string{c.ID.String()},
189-
})
190-
}
191-
192129
// CommitsByRange returns the specific page commits before current revision, every page's number default by CommitsRangeSize
193130
func (c*Commit)CommitsByRange(page,pageSizeint,not,since,untilstring) ([]*Commit,error) {
194131
returnc.repo.commitsByRangeWithTime(c.ID,page,pageSize,not,since,until)
@@ -371,85 +308,6 @@ func (c *Commit) GetBranchName() (string, error) {
371308
returnstrings.SplitN(strings.TrimSpace(data),"~",2)[0],nil
372309
}
373310

374-
// CommitFileStatus represents status of files in a commit.
375-
typeCommitFileStatusstruct {
376-
Added []string
377-
Removed []string
378-
Modified []string
379-
}
380-
381-
// NewCommitFileStatus creates a CommitFileStatus
382-
funcNewCommitFileStatus()*CommitFileStatus {
383-
return&CommitFileStatus{
384-
[]string{}, []string{}, []string{},
385-
}
386-
}
387-
388-
funcparseCommitFileStatus(fileStatus*CommitFileStatus,stdout io.Reader) {
389-
rd:=bufio.NewReader(stdout)
390-
peek,err:=rd.Peek(1)
391-
iferr!=nil {
392-
iferr!=io.EOF {
393-
log.Error("Unexpected error whilst reading from git log --name-status. Error: %v",err)
394-
}
395-
return
396-
}
397-
ifpeek[0]=='\n'||peek[0]=='\x00' {
398-
_,_=rd.Discard(1)
399-
}
400-
for {
401-
modifier,err:=rd.ReadString('\x00')
402-
iferr!=nil {
403-
iferr!=io.EOF {
404-
log.Error("Unexpected error whilst reading from git log --name-status. Error: %v",err)
405-
}
406-
return
407-
}
408-
file,err:=rd.ReadString('\x00')
409-
iferr!=nil {
410-
iferr!=io.EOF {
411-
log.Error("Unexpected error whilst reading from git log --name-status. Error: %v",err)
412-
}
413-
return
414-
}
415-
file=file[:len(file)-1]
416-
switchmodifier[0] {
417-
case'A':
418-
fileStatus.Added=append(fileStatus.Added,file)
419-
case'D':
420-
fileStatus.Removed=append(fileStatus.Removed,file)
421-
case'M':
422-
fileStatus.Modified=append(fileStatus.Modified,file)
423-
}
424-
}
425-
}
426-
427-
// GetCommitFileStatus returns file status of commit in given repository.
428-
funcGetCommitFileStatus(ctx context.Context,repoPath,commitIDstring) (*CommitFileStatus,error) {
429-
stdout,w:=io.Pipe()
430-
done:=make(chanstruct{})
431-
fileStatus:=NewCommitFileStatus()
432-
gofunc() {
433-
parseCommitFileStatus(fileStatus,stdout)
434-
close(done)
435-
}()
436-
437-
stderr:=new(bytes.Buffer)
438-
err:=gitcmd.NewCommand("log","--name-status","-m","--pretty=format:","--first-parent","--no-renames","-z","-1").
439-
AddDynamicArguments(commitID).
440-
WithDir(repoPath).
441-
WithStdout(w).
442-
WithStderr(stderr).
443-
Run(ctx)
444-
w.Close()// Close writer to exit parsing goroutine
445-
iferr!=nil {
446-
returnnil,gitcmd.ConcatenateError(err,stderr.String())
447-
}
448-
449-
<-done
450-
returnfileStatus,nil
451-
}
452-
453311
// GetFullCommitID returns full length (40) of commit ID by given short SHA in a repository.
454312
funcGetFullCommitID(ctx context.Context,repoPath,shortIDstring) (string,error) {
455313
commitID,_,err:=gitcmd.NewCommand("rev-parse").

‎modules/git/commit_sha256_test.go‎

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,6 @@ import (
1414
"github.com/stretchr/testify/require"
1515
)
1616

17-
funcTestCommitsCountSha256(t*testing.T) {
18-
bareRepo1Path:=filepath.Join(testReposDir,"repo1_bare_sha256")
19-
20-
commitsCount,err:=CommitsCount(t.Context(),
21-
CommitsCountOptions{
22-
RepoPath:bareRepo1Path,
23-
Revision: []string{"f004f41359117d319dedd0eaab8c5259ee2263da839dcba33637997458627fdc"},
24-
})
25-
26-
assert.NoError(t,err)
27-
assert.Equal(t,int64(3),commitsCount)
28-
}
29-
30-
funcTestCommitsCountWithoutBaseSha256(t*testing.T) {
31-
bareRepo1Path:=filepath.Join(testReposDir,"repo1_bare_sha256")
32-
33-
commitsCount,err:=CommitsCount(t.Context(),
34-
CommitsCountOptions{
35-
RepoPath:bareRepo1Path,
36-
Not:"main",
37-
Revision: []string{"branch1"},
38-
})
39-
40-
assert.NoError(t,err)
41-
assert.Equal(t,int64(2),commitsCount)
42-
}
43-
4417
funcTestGetFullCommitIDSha256(t*testing.T) {
4518
bareRepo1Path:=filepath.Join(testReposDir,"repo1_bare_sha256")
4619

@@ -157,39 +130,3 @@ func TestHasPreviousCommitSha256(t *testing.T) {
157130
assert.NoError(t,err)
158131
assert.False(t,selfNot)
159132
}
160-
161-
funcTestGetCommitFileStatusMergesSha256(t*testing.T) {
162-
bareRepo1Path:=filepath.Join(testReposDir,"repo6_merge_sha256")
163-
164-
commitFileStatus,err:=GetCommitFileStatus(t.Context(),bareRepo1Path,"d2e5609f630dd8db500f5298d05d16def282412e3e66ed68cc7d0833b29129a1")
165-
assert.NoError(t,err)
166-
167-
expected:=CommitFileStatus{
168-
[]string{
169-
"add_file.txt",
170-
},
171-
[]string{},
172-
[]string{
173-
"to_modify.txt",
174-
},
175-
}
176-
177-
assert.Equal(t,expected.Added,commitFileStatus.Added)
178-
assert.Equal(t,expected.Removed,commitFileStatus.Removed)
179-
assert.Equal(t,expected.Modified,commitFileStatus.Modified)
180-
181-
expected=CommitFileStatus{
182-
[]string{},
183-
[]string{
184-
"to_remove.txt",
185-
},
186-
[]string{},
187-
}
188-
189-
commitFileStatus,err=GetCommitFileStatus(t.Context(),bareRepo1Path,"da1ded40dc8e5b7c564171f4bf2fc8370487decfb1cb6a99ef28f3ed73d09172")
190-
assert.NoError(t,err)
191-
192-
assert.Equal(t,expected.Added,commitFileStatus.Added)
193-
assert.Equal(t,expected.Removed,commitFileStatus.Removed)
194-
assert.Equal(t,expected.Modified,commitFileStatus.Modified)
195-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp