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

feat/git changed paths only #349

Closed
wants to merge 3 commits into from
Closed

Conversation

brianmcgee
Copy link
Member

@brianmcgee brianmcgee commented Jul 9, 2024

If the modified time has not changed when compared with the git index we do not emit the file for processing.

This allows users to introduce treefmt to a repository without suffering an initial large formatting commit.

Instead, files can be formatted incrementally as they are changed.

TODO

Closes #311

@brianmcgee brianmcgee requested a review from zimbatm July 9, 2024 19:18
case Auto:
return Detect(root, pathsCh)
return Detect(root, gitAllFiles, pathsCh)
case Filesystem:
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to emit a warning if gitAllFiles is true in this case?

walk/git.go Outdated Show resolved Hide resolved
walk/git.go Outdated Show resolved Hide resolved
}
// we only want to emit files that have changed when compared with the index
// mod time comparison is done with EPOCH (second) precision as per the POSIX spec
return entry.ModifiedAt.Truncate(time.Second) != info.ModTime().Truncate(time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

Is the entry.ModifiedAt coming from the git commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup

@brianmcgee brianmcgee force-pushed the feat/git-changed-paths-only branch from 1c868e1 to 22718bc Compare July 10, 2024 20:35
If the modified time has not changed when compared with the git index we do not emit the file for processing.

This allows users to introduce treefmt to a repository without suffering an initial large formatting commit.

Instead, files can be formatted incrementally as they are changed.

Closes #311

Signed-off-by: Brian McGee <[email protected]>
@brianmcgee brianmcgee force-pushed the feat/git-changed-paths-only branch 2 times, most recently from 185b47f to 46014f8 Compare July 23, 2024 11:05
Signed-off-by: Brian McGee <[email protected]>
@brianmcgee brianmcgee force-pushed the feat/git-changed-paths-only branch from 46014f8 to 9cfe7db Compare July 23, 2024 13:21
Signed-off-by: Brian McGee <[email protected]>
@brianmcgee brianmcgee force-pushed the feat/git-changed-paths-only branch from 56e15f1 to 352b6e8 Compare July 23, 2024 20:52
@brianmcgee brianmcgee mentioned this pull request Oct 8, 2024
1 task
@brianmcgee
Copy link
Member Author

Closing in favour of #439

@brianmcgee brianmcgee closed this Oct 12, 2024
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.

git: format only files that changed
2 participants