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

Set timestamp on generated files in archive to now #7523

Merged
merged 2 commits into from
Oct 21, 2019
Merged

Set timestamp on generated files in archive to now #7523

merged 2 commits into from
Oct 21, 2019

Conversation

bruceg
Copy link
Contributor

@bruceg bruceg commented Oct 17, 2019

When generating files (Cargo.lock, Cargo.toml, and
.cargo_vcs_info.json), cargo neglected to set any timestamp on the file
in the archive. This results in them being created on disk with a
timestamp of 0 (Jan 1 1970 GMT) which is confusing another tool I use.

This patch alters the behavior to set the mtime to now.

Signed-off-by: Bruce Guenter bruce@untroubled.org

When generating files (Cargo.lock, Cargo.toml, and
.cargo_vcs_info.json), cargo neglected to set any timestamp on the file
in the archive. This results in them being created on disk with a
timestamp of 0 (Jan 1 1970 GMT) which is confusing another tool I use.

This patch alters the behavior to set the mtime to now.

Signed-off-by: Bruce Guenter <bruce@untroubled.org>
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 17, 2019
@alexcrichton
Copy link
Member

Thanks! Could this be updated though to avoid duplication and only calculate this once?

@bruceg
Copy link
Contributor Author

bruceg commented Oct 18, 2019

Moving it into a function would be trivial, and I could sweep the other bits that are duplicated there as well. By "calculate this only once" do you mean in a single place, or once per execution with something like lazy_static?

Signed-off-by: Bruce Guenter <bruce@untroubled.org>
@@ -786,3 +767,28 @@ fn check_filename(file: &Path) -> CargoResult<()> {
}
Ok(())
}

lazy_static::lazy_static! {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to avoid a lazy_static here, it's fine if the times differe by a bit I just wanted to avoid the dance to get the seconds out from being repeated 3 times (which using a helper function fixes)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The lazy_static is just the last commit. Would you prefer a revert commit or just drop the last commit?

Copy link
Member

Choose a reason for hiding this comment

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

It's fine to force-push the branch to drop the commit

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Oct 21, 2019

📌 Commit b33c9e2 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2019
@bors
Copy link
Contributor

bors commented Oct 21, 2019

⌛ Testing commit b33c9e2 with merge 04efd9c...

bors added a commit that referenced this pull request Oct 21, 2019
Set timestamp on generated files in archive to now

When generating files (Cargo.lock, Cargo.toml, and
.cargo_vcs_info.json), cargo neglected to set any timestamp on the file
in the archive. This results in them being created on disk with a
timestamp of 0 (Jan 1 1970 GMT) which is confusing another tool I use.

This patch alters the behavior to set the mtime to now.

Signed-off-by: Bruce Guenter <bruce@untroubled.org>
@bors
Copy link
Contributor

bors commented Oct 21, 2019

☀️ Test successful - checks-azure
Approved by: alexcrichton
Pushing 04efd9c to master...

@bors bors merged commit b33c9e2 into rust-lang:master Oct 21, 2019
Centril added a commit to Centril/rust that referenced this pull request Oct 24, 2019
Update cargo

6 commits in 3a9abe3f065554a7fbc59f440df2baba4a6e47ee..3ba5f27170db10af7a92f2b682e049397197b8fa
2019-10-15 15:55:35 +0000 to 2019-10-22 15:05:18 +0000
- Fix typo in `cargo install --profile` help (rust-lang/cargo#7532)
- Use stricter -Z flag parsing. (rust-lang/cargo#7531)
- Set timestamp on generated files in archive to now (rust-lang/cargo#7523)
- Support rustc's `-Z panic-abort-tests` in Cargo (rust-lang/cargo#7460)
- rustfmt for nightly changes. (rust-lang/cargo#7526)
- Allow --all-features in root of virtual workspace. (rust-lang/cargo#7525)
Centril added a commit to Centril/rust that referenced this pull request Oct 24, 2019
Update cargo

6 commits in 3a9abe3f065554a7fbc59f440df2baba4a6e47ee..3ba5f27170db10af7a92f2b682e049397197b8fa
2019-10-15 15:55:35 +0000 to 2019-10-22 15:05:18 +0000
- Fix typo in `cargo install --profile` help (rust-lang/cargo#7532)
- Use stricter -Z flag parsing. (rust-lang/cargo#7531)
- Set timestamp on generated files in archive to now (rust-lang/cargo#7523)
- Support rustc's `-Z panic-abort-tests` in Cargo (rust-lang/cargo#7460)
- rustfmt for nightly changes. (rust-lang/cargo#7526)
- Allow --all-features in root of virtual workspace. (rust-lang/cargo#7525)
@ehuss ehuss added this to the 1.40.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants