Skip to content

target: rework modtime comparison logic #323#324

Merged
natefinch merged 4 commits into
magefile:masterfrom
SelfDrivingCarp:target-rework
Dec 22, 2020
Merged

target: rework modtime comparison logic #323#324
natefinch merged 4 commits into
magefile:masterfrom
SelfDrivingCarp:target-rework

Conversation

@SelfDrivingCarp
Copy link
Copy Markdown
Contributor

Within the target package:

  • Separate discovery of newest target timestamp from source inspection
  • Allow source inspection functions to bail out as soon as they hit a timestamp newer than the target
~/p/mage/target$ go test -count=1 .
ok      github.com/magefile/mage/target 0.073s

@DavidGamba
Copy link
Copy Markdown

I love this separate approach, the only other thing that I would add to this, which is the reason I don't use mage target is because in the logs I want to see a report of the file I found that was modified. Sometimes there are complex dependency trees and knowing what triggered what is helpful.

@SelfDrivingCarp
Copy link
Copy Markdown
Contributor Author

I started out trying to make it compatible with the upcoming io/fs interfaces to make it easy to write tests that didn't have to touch the filesystem. This would also allow user implementations that return atime, ctime, or other arbitrary times. Ultimately I saw there were already perfectly good unit tests so I got lazy. I might revisit this when io/fs lands and then users can inject whatever funky filesystem behavior they want.

Copy link
Copy Markdown
Member

@natefinch natefinch left a comment

Choose a reason for hiding this comment

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

Mostly LGTM with a couple tiny tweaks

Comment thread target/target.go
Comment thread target/target.go Outdated
Comment thread target/newer.go Outdated
@SelfDrivingCarp
Copy link
Copy Markdown
Contributor Author

Requested changes pushed

@natefinch
Copy link
Copy Markdown
Member

So, coming back to this, now that I better grok why there's an expanded API surface, I'm a little more ok with it. Letting people punch in their own modtime does make the code more flexible.

@natefinch natefinch merged commit 3730191 into magefile:master Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants