Skip to content

feat(api): add date range filtering to commit retrieval endpoints #34497

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

Merged
merged 8 commits into from
May 20, 2025

Conversation

appleboy
Copy link
Member

  • Add support for filtering commits by date range via new "since" and "until" parameters
  • Update API endpoints and command logic to handle the new parameters for fetching commits within given dates
  • Extend API documentation and Swagger specs to describe the new "since" and "until" query parameters
  • Refactor related function signatures and implementations to accept and pass "since" and "until" values

- Add support for filtering commits by date range via new "since" and "until" parameters
- Update API endpoints and command logic to handle the new parameters for fetching commits within given dates
- Extend API documentation and Swagger specs to describe the new "since" and "until" query parameters
- Refactor related function signatures and implementations to accept and pass "since" and "until" values

Signed-off-by: appleboy <[email protected]>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 18, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels May 18, 2025
@appleboy appleboy added modifies/go Pull requests that update Go code and removed modifies/go Pull requests that update Go code labels May 18, 2025
@appleboy appleboy requested a review from Copilot May 18, 2025 15:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds date range filtering to commit retrieval endpoints by introducing new "since" and "until" query parameters. Key changes include updates to the Swagger documentation, modifications to web and API route handlers for commit retrieval, and adjustments in the Git module functions to support the new parameters.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
templates/swagger/v1_json.tmpl Added "since" and "until" query parameter definitions for ISO 8601 date-time filtering.
routers/web/repo/commit.go Updated commit retrieval to include empty "since" and "until" parameters by default.
routers/web/feed/branch.go Updated branch feed logic to include new date filters with default empty values.
routers/api/v1/repo/commits.go Extracted new query parameters and passed them through the API commits retrieval logic.
modules/git/repo_commit.go Introduced commitsByRangeWithTime to support filtering by date range in Git commands.
modules/git/commit.go Updated CommitsByRange to call the new commitsByRangeWithTime function with date filters.

- Quote the values for --since and --until options to handle arguments containing spaces or special characters

Signed-off-by: appleboy <[email protected]>
@lunny
Copy link
Member

lunny commented May 18, 2025

The time parameters needs to be validated and it's better to have some tests.

appleboy added 3 commits May 19, 2025 08:32
- Add validation for 'since' and 'until' parameters to ensure they follow ISO 8601 (RFC3339) format, returning an error if invalid

Signed-off-by: Bo-Yi Wu <[email protected]>
@appleboy
Copy link
Member Author

@lunny See 9deef2d to validate the parameter.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 19, 2025
- Remove single quotes from the --since and --until options in git command invocations
- Refactor command chaining for improved readability in repo_stats.go
- Remove an unused TODO comment from the commits test file

Signed-off-by: Bo-Yi Wu <[email protected]>
appleboy added 2 commits May 20, 2025 08:10
- Remove single quotes from the --since and --until git command options to fix date formatting.

Signed-off-by: Bo-Yi Wu <[email protected]>
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 20, 2025
@lunny lunny merged commit d06eb8d into go-gitea:main May 20, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.25.0 milestone May 20, 2025
@appleboy appleboy deleted the api branch May 20, 2025 02:15
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 21, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Fix ephemeral runner deletion (go-gitea#34447)
  ui: add a default tab on repo header when migrating (go-gitea#34503)
  Use run-name and evaluate workflow variables (go-gitea#34301)
  feat(api): add date range filtering to commit retrieval endpoints (go-gitea#34497)
  Export repo's manual merge settings (go-gitea#34502)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants