Created
January 11, 2010 07:11
-
-
Save mbrezu/274053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script adds and removes .gitignore files to a Visual Studio | |
# project. It is useful when temporary versioning a project with Git. | |
# TODO: add command line handling so the user can specify -r or -a | |
# on the command line, along with the directory name to handle. | |
import sys | |
import os.path | |
import os | |
def createSolutionGitIgnore(path): | |
f = file(os.path.join(path, ".gitignore"), "w") | |
f.write("*.suo\n") | |
f.write("*.vssscc\n") | |
f.close() | |
def createProjectGitIgnore(path): | |
f = file(os.path.join(path, ".gitignore"), "w") | |
f.write("bin/*\n") | |
f.write("obj/*\n") | |
f.write("*.vspscc\n") | |
f.close() | |
if __name__ == "__main__": | |
#os.chdir(r"C:\Temp\Mentolisp") | |
arg = "-a" | |
for cwd, dirs, files in os.walk("."): | |
for filename in files: | |
if arg == '-a': | |
if filename.endswith(".csproj"): | |
createProjectGitIgnore(cwd) | |
if filename.endswith(".sln"): | |
createSolutionGitIgnore(cwd) | |
elif arg == '-r': | |
if filename.endswith(".csproj") or filename.endswith(".sln"): | |
os.unlink(os.path.join(cwd, ".gitignore")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment