gjtorikian / jekyll-last-modified-at

A Jekyll plugin to show the last_modified_at time of a post.
MIT License
243 stars 39 forks source link

Abstract git logic #13

Closed gjtorikian closed 10 years ago

gjtorikian commented 10 years ago

Closes https://github.com/gjtorikian/jekyll-last-modified-at/issues/12

@parkr Would something like this work for your use case? In any event it tidies up the Git stuff and makes no assumptions about whether you're using Git at all.

parkr commented 10 years ago

No, this wouldn't work for my use-case. Ideally, I'd be able to run jekyll build anywhere on my filesystem. Might work better if you do the lookup relative to the build source.

gjtorikian commented 10 years ago

Ahhhhh I got it. One sec.

gjtorikian commented 10 years ago

Damn, this is apparently not an easy thing to do with Git. Pretty sure Dir.chdir is a terrible idea here but there doesn't seem to be a way of finding out, externally, whether a folder is within a Git repo.

The alternative? Given a site dir name, keep amending .git to the path and checking for it. If it's not there, pop up one directory level and do the same thing. Unsure which of these terrible ideas is less bad.

parkr commented 10 years ago

Dir.chdir is not good to do without giving it a block:

# place A
Dir.chdir(source) do
  # now I'm in the source!
end
# now I'm back to place A

Then we don't bork anything with Jekyll's directory discovery :)

gjtorikian commented 10 years ago

@parkr If you can, would you let me know if the changes in this branch satisfy your use case?