summaryrefslogtreecommitdiffstats
path: root/routers
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
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')
-rw-r--r--routers/api/v1/repo/commits.go7
-rw-r--r--routers/web/feed/branch.go2
-rw-r--r--routers/web/repo/commit.go2
3 files changed, 8 insertions, 3 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
diff --git a/routers/web/feed/branch.go b/routers/web/feed/branch.go
index 22b6e2f14b..f13038ff9b 100644
--- a/routers/web/feed/branch.go
+++ b/routers/web/feed/branch.go
@@ -16,7 +16,7 @@ import (
// ShowBranchFeed shows tags and/or releases on the repo as RSS / Atom feed
func ShowBranchFeed(ctx *context.Context, repo *repo.Repository, formatType string) {
- commits, err := ctx.Repo.Commit.CommitsByRange(0, 10)
+ commits, err := ctx.Repo.Commit.CommitsByRange(0, 10, "")
if err != nil {
ctx.ServerError("ShowBranchFeed", err)
return
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index 7439c2411b..93294f8ddd 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -70,7 +70,7 @@ func Commits(ctx *context.Context) {
}
// Both `git log branchName` and `git log commitId` work.
- commits, err := ctx.Repo.Commit.CommitsByRange(page, pageSize)
+ commits, err := ctx.Repo.Commit.CommitsByRange(page, pageSize, "")
if err != nil {
ctx.ServerError("CommitsByRange", err)
return