mryan43 / magic_encoding

Easily manage magic comments for encoding for your ruby 1.9 applications
MIT License
243 stars 27 forks source link

Determine root of project by looking for .git (or others) #11

Open rosstimson opened 10 years ago

rosstimson commented 10 years ago

I recently needed to add encoding comments in a project and remembered that I'd installed this gem. I tried running magic_encoding -h in ~/code and every ruby file in many different projects ended up with # -*- encoding : -h -*- prepended to the file. This has made a huge mess especially trying to work out if git status is showing me files that include changes I was working on or just file with this line added.

Obviously I can fix this but it was pretty annoying and could be a common mistake. I have seen other projects that try and detect the root of a project by looking for the directory that has .git/ (or other VCS files) rather than just recursively going through everything, perhaps this could be implement here.

mryan43 commented 10 years ago

I'm really sorry that happened... however I suppose many of your folders in ~/code had a .git folder in them... so I'm not sure how helpful it would be to try to detect the root using vsc files... however maybe I could write a temp file to be able to magic_encoding rollback :)

On Saturday, February 15, 2014, Ross Timson notifications@github.com wrote:

I recently needed to add encoding comments in a project and remembered that I'd installed this gem. I tried running magic_encoding -h in ~/codeand every ruby file in many different projects ended up with # -- encoding : -h -- prepended to the file. This has made a huge mess especially trying to work out if git status is showing me files that include changes I was working on or just file with this line added.

Obviously I can fix this but it was pretty annoying and could be a common mistake. I have seen other projects that try and detect the root of a project by looking for the directory that has .git/ (or other VCS files) rather than just recursively going through everything, perhaps this could be implement here.

Reply to this email directly or view it on GitHubhttps://github.com/m-ryan/magic_encoding/issues/11 .

rosstimson commented 10 years ago

No need to apologise, I just wanted to flag it up as a possible issue to help others.

You would only modify files at same level or below the .git folder, this however raises the question about what happens if there is no .git folder as would have been the case for me.

A rollback feature would be awesome or maybe a confirmation prompt showing all of the files which will be prepended before going ahead. This might be easier to code and would've been helpful. I usually hate unnecessary prompting but I think it would be acceptable in this case.