Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Created July 25, 2012 18:15
Show Gist options
  • Save sw17ch/3177650 to your computer and use it in GitHub Desktop.
Save sw17ch/3177650 to your computer and use it in GitHub Desktop.
Get all files for a Gemspec using SVN.
# This function asks svn to list the status of all
# files in the repository. Then we filter out files
# that aren't versioned and aren't files.
# See also: svn help st
# $ svn help st
# status (stat, st): Print the status of working copy files and directories.
# ...
# With -v, print full revision information on every item.
def get_svn_files
`svn st -v`.lines.map do |line|
unless line.match(/^\?/)
line.match(/\S+$/)[0]
end
end.compact.reject {|p| File.directory? p}
end
@sw17ch
Copy link
Author

sw17ch commented Jul 25, 2012

I use this instead of svn ls -R -r BASE because the svn list command makes requests to the server. This can feel dreadfully slow at times.

@sw17ch
Copy link
Author

sw17ch commented Jul 25, 2012

Personally, I use it like this

files = get_svn_files
test_files = files.find_all {|f| f.match(/^spec|feature/)}
gem.files = files
gem.test_files = test_files    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment