Closed ExplodingCabbage closed 9 years ago
Hi. Just found this project through the Package Control main page.
The only thing that isn't available on Windows right off the bat would be find
, right around here. However I don't know why you're using a subprocess for this. Python has functions to loop over the filesystem which would be better than invoking an entire process for this. Such as the os.path
library and the os
library.
The rest are git subcommands which are expected to be available for Windows users who have git anyway.
here ... I don't know why you're using a subprocess for this. Python has functions to loop over the filesystem which would be better than invoking an entire process for this.
Yeah, I just leapt on the first piece of code I could copy and paste from Google. It does indeed seem - even to me with almost zero knowledge of Python's filesystem APIs - pretty obviously ugly to be invoking Unix programs to perform basic file system operations.
I'll clean it up this afternoon.
This turns out to be a trickier problem than I thought.
The current master version of this plugin will spawn a command prompt window every 5 seconds if run on Windows.
GitPython is not the solution, as I just lost an hour to learn. At least one of its dependencies, async
, doesn't support Python 3, which Sublime Text 3 uses - and it's abandoned, so that will never change. It's possible that I could work around this by using the current master
version of async
instead of an official release version, but I don't want to build a dependency into a hacked-together mish-mash of incomplete libraries with lots of open bugs into my code.
I'll need to figure out how to suppress that command prompt.
Hey again @Rapptz. My last comment was more a note for myself, but thanks for the input - it's a helpful sanity check. I took a similar approach to the one you propose on a feature branch I need to polish off tonight and get merged back into master; you can see it here: https://github.com/ExplodingCabbage/sublime-gitignorer/blob/windows_maybe/gitignore_plugin.py
Basically I check for platform.system() == 'Windows'
instead of os.name == "nt"
and use a STARTUPINFO
object to explicitly request no window instead of relying upon this being a side effect of shell=true
. I don't know of any downside to doing things my way.
All that's left to polish off this issue is resolving some funkiness with path names:
C:\somedir\somefile
) to the format Sublime requires, with no colon after the drive letter (C\somedir\somefile
).Issue should all be resolved tonight.
I have no idea presently what this would require. Currently all the stuff for interacting with Git is done by
subprocess
calling Unix programs; I don't know anything about the Windows shell, nor how Windows users use Git, so I don't know how easily (if it all) this logic translates to a Windows environment.Perhaps using https://gitorious.org/git-python for all the Git-interacting code would solve this problem easily?