8000 preparations to remove context from repo struct by TheFox0x7 · Pull Request #33893 · go-gitea/gitea · GitHub
[go: up one dir, main page]

Skip to content

preparations to remove context from repo struct #33893

10000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7dee037
add context to GetMergeBase
TheFox0x7 Mar 14, 2025
3631512
add context to GetDiffBinary
TheFox0x7 Mar 14, 2025
162899b
add context to GetPatch
TheFox0x7 Mar 14, 2025
0099c82
use function provided context in GetCompareInfo
TheFox0x7 Mar 14, 2025
34153fd
add context to GetCommitByPath
TheFox0x7 Mar 14, 2025
dfaff77
add context to CommitBetweenLimit
TheFox0x7 Mar 14, 2025
44a6fde
add context to commitsBefore
TheFox0x7 Mar 14, 2025
7fbf350
add context to commitsByRange
TheFox0x7 Mar 14, 2025
3ad5ee2
add contect to GetDiff and SearchCommits
TheFox0x7 Mar 14, 2025
30767c3
add context to FileCommitsCount and FilesCountBetween
TheFox0x7 Mar 14, 2025
1611740
add context to IsCommitInBranch and CommitsBetweenIDs
TheFox0x7 Mar 14, 2025
ea27930
add context to GetTreePathLatestCommit
TheFox0x7 Mar 14, 2025
d2c85c4
add context to CommitsByFileAndRange and FileChangedBetweenCommits
TheFox0x7 Mar 14, 2025
4f1709b
add context to LsTree
TheFox0x7 Mar 14, 2025
3a0af2c
add context to GetRepoRawDiffForFile
TheFox0x7 Mar 14, 2025
8fd4716
add context to GetDiffNumChangedFiles
TheFox0x7 Mar 14, 2025
a4e5604
add context to GetCodeActivityStats
TheFox0x7 Mar 14, 2025
e8f1fb3
add context to LineBlame
TheFox0x7 Mar 14, 2025
00bb0b7
add context to GetDefaultPublicKey
TheFox0x7 Mar 14, 2025
bd41dd4
add context to branch commands
TheFox0x7 Mar 14, 2025
a933423
add context to remaining branch commands
TheFox0x7 Mar 14, 2025
6087fa4
add context to ReadTreeToIndex
TheFox0x7 Mar 14, 2025
ad250db
add context to CommitTree
TheFox0x7 Mar 14, 2025
0d52636
add context to tag commands
TheFox0x7 Mar 14, 2025
6437369
add context to CheckAtrribute
TheFox0x7 Mar 14, 2025
4a60296
fix gogit build
TheFox0x7 Mar 15, 2025
3932669
add context to repo_index commands
TheFox0x7 Mar 15, 2025
97e767e
add context to Size
TheFox0x7 Mar 15, 2025
5122043
fix build
TheFox0x7 Mar 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add context to GetCodeActivityStats
  • Loading branch information
TheFox0x7 committed Mar 16, 2025
commit a4e5604ea149566bebb23794666acad67890909e
4 changes: 2 additions & 2 deletions models/activities/repo_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom
}
defer closer.Close()

code, err := gitRepo.GetCodeActivityStats(timeFrom, repo.DefaultBranch)
code, err := gitRepo.GetCodeActivityStats(ctx, timeFrom, repo.DefaultBranch)
if err != nil {
return nil, fmt.Errorf("FillFromGit: %w", err)
}
Expand All @@ -91,7 +91,7 @@ func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository
}
defer closer.Close()

code, err := gitRepo.GetCodeActivityStats(timeFrom, "")
code, err := gitRepo.GetCodeActivityStats(ctx, timeFrom, "")
if err != nil {
return nil, fmt.Errorf("FillFromGit: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions modules/git/repo_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type CodeActivityAuthor struct {
}

// GetCodeActivityStats returns code statistics for activity page
func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) (*CodeActivityStats, error) {
func (repo *Repository) GetCodeActivityStats(ctx context.Context, fromTime time.Time, branch string) (*CodeActivityStats, error) {
stats := &CodeActivityStats{}

since := fromTime.Format(time.RFC3339)

stdout, _, runErr := NewCommand("rev-list", "--count", "--no-merges", "--branches=*", "--date=iso").AddOptionFormat("--since='%s'", since).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
stdout, _, runErr := NewCommand("rev-list", "--count", "--no-merges", "--branches=*", "--date=iso").AddOptionFormat("--since='%s'", since).RunStdString(ctx, &RunOpts{Dir: repo.Path})
if runErr != nil {
return nil, runErr
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string)
}

stderr := new(strings.Builder)
err = gitCmd.Run(repo.Ctx, &RunOpts{
err = gitCmd.Run(ctx, &RunOpts{
Env: []string{},
Dir: repo.Path,
Stdout: stdoutWriter,
Expand Down
2 changes: 1 addition & 1 deletion modules/git/repo_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestRepository_GetCodeActivityStats(t *testing.T) {
timeFrom, err := time.Parse(time.RFC3339, "2016-01-01T00:00:00+00:00")
assert.NoError(t, err)

code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
code, err := bareRepo1.GetCodeActivityStats(t.Context(), timeFrom, "")
assert.NoError(t, err)
assert.NotNil(t, code)

Expand Down
0