diff options
| author | Dickson S. Guedes | 2011-10-07 01:49:47 +0000 |
|---|---|---|
| committer | Dickson S. Guedes | 2011-10-07 01:49:47 +0000 |
| commit | 9ec50ee7556539e903ca3ee076d5ba07fdf0c5be (patch) | |
| tree | fb5459eddf3ca1ff539685a63e355d4694474b2e /lib | |
| parent | fcea520370dd07d84e07660a09e2baf5ed8e4b31 (diff) | |
adding git support, ref #16
Added more example to README
Now pgxn_utils notice the repository creation
Now pgxn_utils do an initial commit
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pgxn_utils/cli.rb | 5 | ||||
| -rw-r--r-- | lib/pgxn_utils/no_tasks.rb | 22 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/pgxn_utils/cli.rb b/lib/pgxn_utils/cli.rb index 412fc24..65e0487 100644 --- a/lib/pgxn_utils/cli.rb +++ b/lib/pgxn_utils/cli.rb @@ -7,7 +7,6 @@ module PgxnUtils include Thor::Actions include PgxnUtils::NoTasks - include Grit desc "skeleton extension_name", "Creates an extension skeleton in current directory" @@ -31,7 +30,7 @@ module PgxnUtils if is_extension?("#{self.target}/#{extension_name}") say "'#{extension_name}' already exists. Please, use 'change' instead 'skeleton'.", :red - elsif is_extension?(".") + elsif is_extension?(self.target) say "You are inside a extension directory, already. Consider use 'change' instead.", :red elsif is_dir?("#{self.target}/#{extension_name}") say "Can't create an extension overwriting an existing directory.", :red @@ -39,7 +38,7 @@ module PgxnUtils self.set_accessors extension_name directory "root", extension_name - Repo.init("#{self.target}/#{extension_name}") if options[:git] + init_repository("#{self.target}/#{extension_name}") if options[:git] end end diff --git a/lib/pgxn_utils/no_tasks.rb b/lib/pgxn_utils/no_tasks.rb index a066998..abbd455 100644 --- a/lib/pgxn_utils/no_tasks.rb +++ b/lib/pgxn_utils/no_tasks.rb @@ -2,6 +2,28 @@ 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 make_dist_clean(path) inside path do |
