Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
Last active December 14, 2015 04:39
Show Gist options
  • Save ongaeshi/5030011 to your computer and use it in GitHub Desktop.
Save ongaeshi/5030011 to your computer and use it in GitHub Desktop.
svn:ignore to .gitignore. (Support several more ignore settings)

Usage

$ cd ~/Documents/tortoisesvn
$ svnignore2gitignore.rb > .gitignore

Sample Output

.tx
Desktop.ini
MYBUILD
Tools
bin
cov-int
default.build.user
default.user
gpgpassphrase.txt
obj
signinfo.txt
tools
version.build
src/AsyncFramework/*.user
doc/xsl/es/userconfig.xml
ext/openssl/*.bat
ext/openssl/*.bak
ext/openssl/Makefile
ext/openssl/MINFO
ext/openssl/inc32
.
.
require 'kconv'
str = `svn propget -R svn:ignore`.toutf8
# str = `svn propget -R svn:ignore`
lines = str.gsub('\\', '/').split("\n").find_all{|v| !v.empty?}
head = ""
puts lines.map { |line|
head, line = $1, $2 if line =~ /(.*) - (.*)/
File.join(head, line).sub(/^.\//, "")
}.sort.to_a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment