Skip to content
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

Fix push mirror, wrong timestamp format #27153

Merged
merged 6 commits into from
Sep 23, 2023
Merged

Conversation

kilimnik
Copy link
Contributor

@kilimnik kilimnik commented Sep 20, 2023

I noticed, that the push mirrors endpoint, is the only endpoint which returns the times in long format rather than as time.Time().

I think the behavior should be consistent across the project.


⚠️ BREAKING ⚠️

This PR changes the time format used in API responses for all push_mirror endpoints which return a push mirror.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 20, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 20, 2023
Copy link
Member

@KN4CK3R KN4CK3R left a comment

Choose a reason for hiding this comment

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

This is a breaking change. Please add a note into the PR description.

I added the template for you.

@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 Sep 20, 2023
@KN4CK3R KN4CK3R added the pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! label Sep 20, 2023
@github-actions github-actions bot added the modifies/api This PR adds API routes or modifies them label Sep 20, 2023
@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 Sep 20, 2023
@lunny lunny added this to the 1.22.0 milestone Sep 21, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 21, 2023
modules/structs/mirror.go Outdated Show resolved Hide resolved
@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 21, 2023
@kilimnik
Copy link
Contributor Author

As this is a small fix, could this be merged into the 1.21.0 milestone?

CreatedUnix: pm.CreatedUnix.FormatLong(),
LastUpdateUnix: pm.LastUpdateUnix.FormatLong(),
CreatedUnix: pm.CreatedUnix.AsTime(),
LastUpdateUnix: pm.LastUpdateUnix.AsTimePtr(),
Copy link
Member

Choose a reason for hiding this comment

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

But pm.LastUpdateUnix maybe nil.

Copy link
Member

Choose a reason for hiding this comment

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

pm.LastUpdateUnix is a timeutil.TimeStamp not *timeutil.TimeStamp. It can only be pm.LastUpdateUnix.IsZero() if I'm not mistaken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was also a bit confused about that. So I guess I change it back to not be a pointer?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, so maybe we should change

// AsTimePtrInLocation convert timestamp as *time.Time in customize location
func (ts TimeStamp) AsTimePtrInLocation(loc *time.Location) *time.Time {
	tm := time.Unix(int64(ts), 0).In(loc)
	return &tm
}

to

// AsTimePtrInLocation convert timestamp as *time.Time in customize location
func (ts TimeStamp) AsTimePtrInLocation(loc *time.Location) *time.Time {
  if ts.IsZero() {
      return nil
  }
	tm := time.Unix(int64(ts), 0).In(loc)
	return &tm
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I guess this is resolved and the proposed change should be done in a different PR?

@silverwind silverwind added the backport/v1.21 This PR should be backported to Gitea 1.21 label Sep 21, 2023
@KN4CK3R
Copy link
Member

KN4CK3R commented Sep 22, 2023

Do we backport breaking changes? I don't see this PR as a bug fix.

@silverwind silverwind removed the backport/v1.21 This PR should be backported to Gitea 1.21 label Sep 22, 2023
@silverwind
Copy link
Member

Agree, it's probably better not to backport, sorry @kilimnik.

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 23, 2023
@silverwind silverwind enabled auto-merge (squash) September 23, 2023 11:02
@silverwind silverwind merged commit 0ee7cbf into go-gitea:main Sep 23, 2023
25 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 23, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 25, 2023
* giteaofficial/main:
  Add missing public user visibility in user details page (go-gitea#27246)
  Use mask-based fade-out effect for `.new-menu` (go-gitea#27181)
  [skip ci] Updated translations via Crowdin
  Fix z-index on markdown completion (go-gitea#27237)
  Update database-preparation and add note re: MariaDB (go-gitea#27232)
  cleanup locale function usage (go-gitea#27227)
  Fix EOL handling in web editor (go-gitea#27141)
  Fix PushEvent NullPointerException jenkinsci/github-plugin (go-gitea#27203)
  fix issues on action runners page (go-gitea#27226)
  Fix Fomantic UI dropdown icon bug when there is a search input in menu (go-gitea#27225)
  Update go-enry to 2.8.5 (go-gitea#27215)
  Update nodejs installation method in release container (go-gitea#27207)
  Quote table `release` in sql queries (go-gitea#27205)
  Fix push mirror, wrong timestamp format (go-gitea#27153)
  Allow copying issue comment link on archived repos and when not logged in (go-gitea#27193)
  fix: text decorator on issue sidebar menu label (go-gitea#27206)
  Update JS and Poetry dependencies and eslint (go-gitea#27200)
  Remove some dead code (go-gitea#27196)

# Conflicts:
#	templates/repo/issue/view_content/context_menu.tmpl
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 pr/breaking Merging this PR means builds will break. Needs a description what exactly breaks, and how to fix it! size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants