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

ファイルの最終更新をgit logから取れたら取る #117

Closed
Songmu opened this issue Oct 28, 2023 · 0 comments · Fixed by #118
Closed

ファイルの最終更新をgit logから取れたら取る #117

Songmu opened this issue Oct 28, 2023 · 0 comments · Fixed by #118

Comments

@Songmu
Copy link
Member

Songmu commented Oct 28, 2023

今、エントリーのファイルの更新時間をリモートと比較する時にファイルのmtimeを使っている。しかし今どきmtimeだけというのも頼りない。例えば、CIとかでgit cloneしてきた直後などはmtimeが全部現在時間になってしまい、ローカルが全部リモートより新しいと判定されてしまうなどがある。 (gitにはsvnのuse-commit-times的な機能はオフィシャルで存在しないし / 以前 git-set-mtime をメンテしていた)

git履歴からファイルの更新日時が取れる場合はそれを使うようにしたい。VCSでgitを特別扱いするのはどうなのか、blogsyncがgitに依存するのはどうなのか、という議論はあるが、実際問題git管理している人も多かろうと思うので悪くないのではないか。

以下のようにすれば、gitが入っていな環境や、そのファイルがgit管理されていないケースでもそれを壊さないはず。

  • gitコマンドが入っているか確認する
  • 当該ファイルがgit管理されているか確認する
  • そのファイルがgit上でクリーンか(modifiedになっていないか)確認する
  • 上記の条件を満たした場合、そのファイルのgit上の最終更新時間を、そのファイルの最終更新時間として扱う
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 a pull request may close this issue.

1 participant