Add ability to specify '--not' from GetAllCommits (#24409)
For my specific use case, I'd like to get all commits that are on one branch but NOT on the other branch. For instance, I'd like to get all the commits on `Branch1` that are not also on `master` (I.e. all commits that were made after `Branch1` was created). This PR adds a `not` query param that gets passed down to the `git log` command to allow the user to exclude items from `GetAllCommits`. See [git documentation](https://git-scm.com/docs/git-log#Documentation/git-log.txt---not) --------- Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
@ -90,14 +90,22 @@ func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) {
|
||||
return commits[0], nil
|
||||
}
|
||||
|
||||
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int) ([]*Commit, error) {
|
||||
stdout, _, err := NewCommand(repo.Ctx, "log").
|
||||
AddOptionFormat("--skip=%d", (page-1)*pageSize).AddOptionFormat("--max-count=%d", pageSize).AddArguments(prettyLogFormat).
|
||||
AddDynamicArguments(id.String()).
|
||||
RunStdBytes(&RunOpts{Dir: repo.Path})
|
||||
func (repo *Repository) commitsByRange(id SHA1, page, pageSize int, not string) ([]*Commit, error) {
|
||||
cmd := NewCommand(repo.Ctx, "log").
|
||||
AddOptionFormat("--skip=%d", (page-1)*pageSize).
|
||||
AddOptionFormat("--max-count=%d", pageSize).
|
||||
AddArguments(prettyLogFormat).
|
||||
AddDynamicArguments(id.String())
|
||||
|
||||
if not != "" {
|
||||
cmd.AddOptionValues("--not", not)
|
||||
}
|
||||
|
||||
stdout, _, err := cmd.RunStdBytes(&RunOpts{Dir: repo.Path})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return repo.parsePrettyFormatLogToList(stdout)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user