Skip to content

Storing branch commits count in db rather than caching them in memory or redis #33954

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

Closed
Prev Previous commit
Fix build
  • Loading branch information
lunny committed Apr 29, 2025
commit adbea8bdb9ee2c989fd72b745d623dec2752313c
10 changes: 5 additions & 5 deletions modules/git/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ func RefNameFromCommit(shortName string) RefName {
return RefName(shortName)
}

func RefNameFromObjectTypeAndShortName(objectType ObjectType, shortName string) RefName {
switch objectType {
case ObjectBranch:
func RefNameFromRefTypeAndShortName(refType RefType, shortName string) RefName {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should never need it.

Why you know "RefType" but don't know the full "RefName" when using the ref?

switch refType {
case RefTypeBranch:
return RefNameFromBranch(shortName)
case ObjectTag:
case RefTypeTag:
return RefNameFromTag(shortName)
case ObjectCommit:
case RefTypeCommit:
return RefNameFromCommit(shortName)
}
return RefName(shortName)
Expand Down
2 changes: 1 addition & 1 deletion services/repository/files/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, refCommit *ut
}
selfURLString := selfURL.String()

refName := git.RefNameFromObjectTypeAndShortName(refType, refCommit.InputRef)
refName := git.RefNameFromRefTypeAndShortName(refType, refCommit.InputRef)

commitsCount, _ := context_service.GetRefCommitsCount(ctx, repo.ID, gitRepo, refName)

Expand Down
Loading