diff options
author | Dickson S. Guedes | 2011-10-12 22:35:19 +0000 |
---|---|---|
committer | Dickson S. Guedes | 2011-10-12 22:35:19 +0000 |
commit | 91ae5ef24352af905d6c8d530fbfaa28e1e15426 (patch) | |
tree | 66440e87fe9cb7a60d6c6a9d6113292218516a97 /lib/pgxn_utils/no_tasks.rb | |
parent | da852cd006cfd841fddb78fb363a0c3fb315dfe2 (diff) | |
parent | ef10e820f22f190a2a16dfc06b15a7b6f645b7d4 (diff) |
Added git support.
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 |