Skip to content

fix: if Mirrors repo no content is fetched, updated time should not b… #3551

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 5 commits into from
Feb 23, 2018

Conversation

appleboy
Copy link
Member

@appleboy appleboy commented Feb 21, 2018

maybe fix #3548 and #1329

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Feb 21, 2018
@@ -264,6 +264,21 @@ func SyncMirrors() {
log.Error(4, "UpdateMirror [%s]: %v", repoID, err)
continue
}

Copy link
Member

Choose a reason for hiding this comment

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

But line 263 has updated all the columns of the records.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. It only update the NextUpdateUnix value. Right?

Copy link
Member Author

Choose a reason for hiding this comment

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

but we need to update the updated_unix field of repo table.

Copy link
Member

Choose a reason for hiding this comment

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

@appleboy. No. It should only update NextUpdateUnix maybe I don't know. But in fact it will update all the columns included updated_unix. So that your PR will update the record twice.

Copy link
Member Author

@appleboy appleboy Feb 21, 2018

Choose a reason for hiding this comment

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

@lunny Line 263 just update the mirror table and this PR update updated_unix field on the other table repository

Copy link
Member

Choose a reason for hiding this comment

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

Oh, yes you are right. And maybe you can also refactor there to use one DB connection but not get connection from cache.

Copy link
Member Author

Choose a reason for hiding this comment

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

@lunny Done. See e5e8765

@codecov-io
Copy link

codecov-io commented Feb 21, 2018

Codecov Report

Merging #3551 into master will decrease coverage by <.01%.
The diff coverage is 20%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3551      +/-   ##
==========================================
- Coverage   35.78%   35.77%   -0.01%     
==========================================
  Files         285      285              
  Lines       40841    40850       +9     
==========================================
  Hits        14615    14615              
- Misses      24058    24067       +9     
  Partials     2168     2168
Impacted Files Coverage Δ
models/repo_mirror.go 4% <20%> (+0.98%) ⬆️
models/repo_list.go 65.62% <0%> (-1.57%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7cea92...9dbd43e. Read the comment docs.

@appleboy appleboy modified the milestones: 1.5.0, 1.4.0 Feb 21, 2018
if err != nil {
log.Error(2, "GetLatestCommitDate [%s]: %v", m.RepoID, err)
continue
} else if commitDate.Before(*m.Repo.UpdatedUnix.AsTimePtr()) {
Copy link
Member

Choose a reason for hiding this comment

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

  1. This will not fix already invalid values
  2. If mirrored repo last commit is deleted with force push, this will not update to new latest commits time

Can't this be checked so to skip only when updated_unix equals commit time?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lafriks You are right. Removed the following check.

if commitDate.Before(*m.Repo.UpdatedUnix.AsTimePtr())

@tboerger tboerger 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 Feb 22, 2018
@appleboy
Copy link
Member Author

@lafriks Waiting for your response.


// Get latest commit date and compare to current repository updated time,
// update if latest commit date is newer.
commitDate, err := git.GetLatestCommitTime(m.Repo.RepoPath())
Copy link
Member

Choose a reason for hiding this comment

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

Comment should also be fixed as there is no check anymore

Copy link
Member Author

Choose a reason for hiding this comment

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

See ac27f46

Signed-off-by: Bo-Yi Wu <[email protected]>
@lafriks lafriks modified the milestones: 1.4.0, 1.5.0 Feb 22, 2018
@lunny lunny merged commit 845ba9d into go-gitea:master Feb 23, 2018
appleboy added a commit to appleboy/gitea that referenced this pull request Feb 23, 2018
go-gitea#3551)

* fix: if Mirrors repo no content is fetched, updated time should not be changed

* fix: sync update time from mirror repo.

* fix: one single session.

* update comment.

Signed-off-by: Bo-Yi Wu <[email protected]>
@appleboy appleboy deleted the patch-11 branch February 23, 2018 01:08
lafriks pushed a commit that referenced this pull request Feb 23, 2018
@lafriks lafriks added the backport/done All backports for this PR have been created label Feb 23, 2018
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mirror: if no content is fetched, updated should not be changed
6 participants