diff options
Diffstat (limited to 'lib/pgxn_utils/no_tasks.rb')
-rw-r--r-- | lib/pgxn_utils/no_tasks.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/pgxn_utils/no_tasks.rb b/lib/pgxn_utils/no_tasks.rb index a066998..9dc62ad 100644 --- a/lib/pgxn_utils/no_tasks.rb +++ b/lib/pgxn_utils/no_tasks.rb @@ -2,6 +2,33 @@ module PgxnUtils module NoTasks include PgxnUtils::Constants + include Grit + + def init_repository(extension_dir) + repo = Repo.init(extension_dir) + original_dir = File.expand_path "." + + if repo + say_status :init, "#{extension_dir}", :green + + FileUtils.chdir extension_dir + repo.add "." + if repo.commit_index("initial commit") + say_status :commit, "initial commit", :green + else + say_status :failed, "initial commit", :red + end + else + say_status :error, " initializing #{extension_dir}", :red + end + + FileUtils.chdir original_dir + end + + def is_dirty?(extension_dir) + repo = Repo.init(extension_dir) + repo.status.map(&:type).uniq != [nil] + end def make_dist_clean(path) inside path do @@ -77,6 +104,27 @@ module PgxnUtils [ extension_path, extension_name ] end + def has_scm?(path) + begin + Repo.new(path) + rescue Grit::InvalidGitRepositoryError + false + end + end + + def scm_archive(path, archive, prefix, treeish='master') + git = Git.new(Repo.new(path).path) + git.archive({:format => "zip", :prefix => prefix, :output => archive}, treeish) + end + + def zip_archive(path, archive, prefix) + Zippy.create(archive) do |zip| + Dir["#{path}/**/**"].each do |file| + zip["#{prefix}#{file.sub(path+'/','')}"] = File.open(file) unless File.directory?(file) + end + end + end + def can_zip?(archive) can_zip = false |