aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/commits.go
diff options
context:
space:
mode:
authorMatthew Walowski <mattwalowski@gmail.com>2023-04-29 05:34:14 -0700
committerGitHub <noreply@github.com>2023-04-29 08:34:14 -0400
commitf766b002938b5c81e343c81fda3c0669fa09809f (patch)
treed0d5baa5d120b81c18721b7de2f46d2b855f6b0f /routers/api/v1/repo/commits.go
parent241b74f6c536c1d7de3b4e79e552bf1a3264cc6d (diff)
downloadgitea-f766b002938b5c81e343c81fda3c0669fa09809f.tar.gz
gitea-f766b002938b5c81e343c81fda3c0669fa09809f.zip
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>
Diffstat (limited to 'routers/api/v1/repo/commits.go')
-rw-r--r--routers/api/v1/repo/commits.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go
index 22b013e7dc..401403c83d 100644
--- a/routers/api/v1/repo/commits.go
+++ b/routers/api/v1/repo/commits.go
@@ -115,6 +115,10 @@ func GetAllCommits(ctx *context.APIContext) {
// in: query
// description: page size of results (ignored if used with 'path')
// type: integer
+ // - name: not
+ // in: query
+ // description: commits that match the given specifier will not be listed.
+ // type: string
// responses:
// "200":
// "$ref": "#/responses/CommitList"
@@ -181,7 +185,8 @@ func GetAllCommits(ctx *context.APIContext) {
}
// Query commits
- commits, err = baseCommit.CommitsByRange(listOptions.Page, listOptions.PageSize)
+ not := ctx.FormString("not")
+ commits, err = baseCommit.CommitsByRange(listOptions.Page, listOptions.PageSize, not)
if err != nil {
ctx.Error(http.StatusInternalServerError, "CommitsByRange", err)
return