Repository: go-gitea/gitea
File: services/repository/push.go (Go)

Code before:
			return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
		}
	}

	l, err := newCommit.CommitsBeforeLimit(10)
	if err != nil {
		return nil, fmt.Errorf("newCommit.CommitsBeforeLimit: %w", err)
	}
	notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID)
	return l, nil
}

func pushUpdateBranch(_ context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions, newCommit *git.Commit) ([]*git.Commit, error) {
	l, err := newCommit.CommitsBeforeUntil(opts.OldCommitID)
	if err != nil {
		return nil, fmt.Errorf("newCommit.CommitsBeforeUntil: %w", err)
	}

	branch := opts.RefFullName.BranchName()

	isForcePush, err := newCommit.IsForcePush(opts.OldCommitID)
	if err != nil {
		log.Error("IsForcePush %s:%s failed: %v", repo.FullName(), branch, err)
	}

	// only update branch can trigger pull request task because the pull request hasn't been created yet when creaing a branch
	go pull_service.AddTestPullRequestTask(pull_service.TestPullRequestOptions{
		RepoID:      repo.ID,
		Doer:        pusher,
		Branch:      branch,
		IsSync:      true,
		IsForcePush: isForcePush,
		OldCommitID: opts.OldCommitID,
		NewCommitID: opts.NewCommitID,
	})

	if isForcePush {
		log.Trace("Push %s is a force push", opts.NewCommitID)

		cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
	} else {
		// TODO: increment update the commit count cache but not remove
		cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
	}

	return l, nil
}

func pushDeleteBranch(ctx context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions) {
	notify_service.DeleteRef(ctx, pusher, repo, opts.RefFullName)


Review comment (suggestion):
```suggestion
	// only update branch can trigger pull request task because the pull request hasn't been created yet when creating a branch
```

typo

Code after:
			return nil, fmt.Errorf("UpdateRepositoryCols: %w", err)
		}
	}

	l, err := newCommit.CommitsBeforeLimit(10)
	if err != nil {
		return nil, fmt.Errorf("newCommit.CommitsBeforeLimit: %w", err)
	}
	notify_service.CreateRef(ctx, pusher, repo, opts.RefFullName, opts.NewCommitID)
	return l, nil
}

func pushUpdateBranch(_ context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions, newCommit *git.Commit) ([]*git.Commit, error) {
	l, err := newCommit.CommitsBeforeUntil(opts.OldCommitID)
	if err != nil {
		return nil, fmt.Errorf("newCommit.CommitsBeforeUntil: %w", err)
	}

	branch := opts.RefFullName.BranchName()

	isForcePush, err := newCommit.IsForcePush(opts.OldCommitID)
	if err != nil {
		log.Error("IsForcePush %s:%s failed: %v", repo.FullName(), branch, err)
	}

	// only update branch can trigger pull request task because the pull request hasn't been created yet when creating a branch
	go pull_service.AddTestPullRequestTask(pull_service.TestPullRequestOptions{
		RepoID:      repo.ID,
		Doer:        pusher,
		Branch:      branch,
		IsSync:      true,
		IsForcePush: isForcePush,
		OldCommitID: opts.OldCommitID,
		NewCommitID: opts.NewCommitID,
	})

	if isForcePush {
		log.Trace("Push %s is a force push", opts.NewCommitID)

		cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
	} else {
		// TODO: increment update the commit count cache but not remove
		cache.Remove(repo.GetCommitsCountCacheKey(opts.RefName(), true))
	}

	return l, nil
}

func pushDeleteBranch(ctx context.Context, repo *repo_model.Repository, pusher *user_model.User, opts *repo_module.PushUpdateOptions) {
	notify_service.DeleteRef(ctx, pusher, repo, opts.RefFullName)