Skip to content
Browse files

adding git support, ref #16

Added more example to README
Now pgxn_utils notice the repository creation
Now pgxn_utils do an initial commit
  • Loading branch information...
1 parent fcea520 commit 9ec50ee7556539e903ca3ee076d5ba07fdf0c5be @guedes guedes committed
Showing with 88 additions and 34 deletions.
  1. +40 −16 README.md
  2. +24 −10 Rakefile
  3. +2 −3 lib/pgxn_utils/cli.rb
  4. +22 −0 lib/pgxn_utils/no_tasks.rb
  5. +0 −5 spec/cli_spec.rb
View
56 README.md
@@ -4,7 +4,7 @@ pgxn utils
What is it?
--------
-It aims to be a set of task to help PostgreSQL extension's developers to focus more on the problem that they wants to solve than in all structure and files and control files need to PGXS to build the extension.
+It aims to be a set of task to help PostgreSQL extension's developers to focus more on the problem that they wants to solve than in the structure and files and control files need to PGXS to build the extension.
How to install it?
------------------
@@ -17,24 +17,27 @@ Or you can install it by rubygems:
gem install pgxn_utils
+
How it works?
-------------
-It is all about tasks. Let's see what tasks we have:
+It is all about tasks. Let's see them:
- $ pgxn_utils help
+ $ pgxn-utils help
Tasks:
- pgxn_utils bundle [extension_name] # Bundles an extension.
- pgxn_utils change [extension_name] # Change META's attributes in current extension.
- pgxn_utils help [TASK] # Describe available tasks or one specific task
- pgxn_utils release filename # Release a extension
- pgxn_utils skeleton extension_name # Creates an extension skeleton in current directory.
+ pgxn-utils bundle [extension_name] # Bundles the extension in a zip file
+ pgxn-utils change [extension_name] # Changes META's attributes in current extension
+ pgxn-utils help [TASK] # Describe available tasks or one specific task
+ pgxn-utils release filename # Release an extension to PGXN
+ pgxn-utils skeleton extension_name # Creates an extension skeleton in current directory
+
# Creating a new extension
- $ pgxn_utils skeleton my_cool_extension
+ $ pgxn-utils skeleton my_cool_extension
create my_cool_extension
create my_cool_extension/my_cool_extension.control
+ create my_cool_extension/.gitignore
create my_cool_extension/META.json
create my_cool_extension/Makefile
create my_cool_extension/README.md
@@ -44,13 +47,32 @@ It is all about tasks. Let's see what tasks we have:
create my_cool_extension/test/expected/base.out
create my_cool_extension/test/sql/base.sql
+You can start creating an extension with or without version control. By default `pgxn-utils`
+supports (git)[http://git-scm.org] but it will not create a repository unless you use `--git`
+option in the skeleton task.
+
+ $ pgxn-utils skeleton my_cool_versioned_extension --git
+ create my_cool_versioned_extension
+ create my_cool_versioned_extension/my_cool_versioned_extension.control
+ create my_cool_versioned_extension/.gitignore
+ create my_cool_versioned_extension/META.json
+ create my_cool_versioned_extension/Makefile
+ create my_cool_versioned_extension/README.md
+ create my_cool_versioned_extension/doc/my_cool_versioned_extension.md
+ create my_cool_versioned_extension/sql/my_cool_versioned_extension.sql
+ create my_cool_versioned_extension/sql/uninstall_my_cool_versioned_extension.sql
+ create my_cool_versioned_extension/test/expected/base.out
+ create my_cool_versioned_extension/test/sql/base.sql
+ init /tmp/my_cool_versioned_extension
+ commit initial commit
+
Thats it! Just start coding! ":)
# Changing something
Well suppose you want to change the default maintainer's name and the license, well just do:
- $ pgxn_utils change my_cool_extension --maintainer "Dickson Guedes" --license bsd
+ $ pgxn-utils change my_cool_extension --maintainer "Dickson Guedes" --license bsd
conflict META.json
Overwrite /tmp/my_cool_extension/META.json? (enter "h" for help) [Ynaqdh] d
{
@@ -82,16 +104,17 @@ Well suppose you want to change the default maintainer's name and the license, w
}
Retrying...
Overwrite /tmp/my_cool_extension/META.json? (enter "h" for help) [Ynaqdh] Y
- force META.json
+ force META.json
identical my_cool_extension.control
+
It will wait you decide what to do.
For all switches that you can use with *change*, type:
- $ pgxn_utils help change
+ $ pgxn-utils help change
Usage:
- pgxn_utils change [extension_name]
+ pgxn-utils change [extension_name]
Options:
-p, [--target=TARGET] # Define the target directory
@@ -105,7 +128,8 @@ For all switches that you can use with *change*, type:
-t, [--tags=one two three] # Defines extension's tags
-r, [--release-status=RELEASE_STATUS] # Initial extension's release status
- Change META's attributes in current extension.
+ Changes META's attributes in current extension
+
# Bundling and Releasing!
@@ -113,12 +137,12 @@ Well, since you finished your work you can bundle it to send to [PGXN](http://pg
Bundle it:
- $ pgxn_utils bundle my_cool_extension
+ $ pgxn-utils bundle my_cool_extension
Extension generated at: /home/guedes/extensions/my_cool_extension-0.0.1.zip
and release it:
- $ pgxn_utils release my_cool_extension-0.0.1.zip
+ $ pgxn-utils release my_cool_extension-0.0.1.zip
Enter your PGXN username: guedes
Enter your PGXN password: ******
Trying to release my_cool_extension-0.0.1.zip ... released successfully!
View
34 Rakefile
@@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
def format_cmd_output(cmd)
- `./bin/pgxn_utils #{cmd} | sed 's/^/ /' | sed 's/\[[0-9]*m//g'`
+ `./bin/pgxn-utils #{cmd} | sed 's/^/ /' | sed 's/\[[0-9]*m//g'`
end
desc "Run RSpec"
@@ -22,6 +22,7 @@ end
desc "Generate README.md"
task :generate_readme do
rm_r "/tmp/my_cool_extension" if File.exist?("/tmp/my_cool_extension")
+ rm_r "/tmp/my_cool_versioned_extension" if File.exist?("/tmp/my_cool_versioned_extension")
readme = File.new("README.md.new", 'w')
readme.puts <<-README
pgxn utils
@@ -30,40 +31,53 @@ pgxn utils
What is it?
--------
-It aims to be a set of task to help PostgreSQL extension's developers to focus more on the problem that they wants to solve than in the all structure and files and control files need to PGXS to build the extension.
+It aims to be a set of task to help PostgreSQL extension's developers to focus more on the problem that they wants to solve than in all structure and files and control files need to PGXS to build the extension.
How to install it?
------------------
+If you have pgxn client installed you can do:
+
+ pgxn install pgxn_utils
+
+Or you can install it by rubygems:
+
gem install pgxn_utils
How it works?
-------------
-It is all about tasks. Let's see what tasks we have:
+It is all about tasks. Let's see them:
- $ pgxn_utils help
+ $ pgxn-utils help
#{format_cmd_output("help")}
# Creating a new extension
- $ pgxn_utils skeleton my_cool_extension
+ $ pgxn-utils skeleton my_cool_extension
#{format_cmd_output("skeleton my_cool_extension -p /tmp")}
+You can start creating an extension with or without version control. By default `pgxn-utils`
+supports (git)[http://git-scm.org] but it will not create a repository unless you use `--git`
+option in the skeleton task.
+
+ $ pgxn-utils skeleton my_cool_versioned_extension --git
+#{format_cmd_output("skeleton my_cool_versioned_extension --git -p /tmp")}
+
Thats it! Just start coding! ":)
# Changing something
-Well suppose you want to change the default maintainer's name and the license, well just do:
+Well suppose you want to change the default maintainer's name and the license, just do:
- $ pgxn_utils change my_cool_extension --maintainer "Dickson Guedes" --license bsd
+ $ pgxn-utils change my_cool_extension --maintainer "Dickson Guedes" --license bsd
#{format_cmd_output("change my_cool_extension -p /tmp --maintainer 'Dickson Guedes' --license bsd")}
It will wait you decide what to do.
For all switches that you can use with *change*, type:
- $ pgxn_utils help change
+ $ pgxn-utils help change
#{format_cmd_output("help change")}
# Bundling and Releasing!
@@ -72,12 +86,12 @@ Well, since you finished your work you can bundle it to send to [PGXN](http://pg
Bundle it:
- $ pgxn_utils bundle my_cool_extension
+ $ pgxn-utils bundle my_cool_extension
Extension generated at: /home/guedes/extensions/my_cool_extension-0.0.1.zip
and release it:
- $ pgxn_utils release my_cool_extension-0.0.1.zip
+ $ pgxn-utils release my_cool_extension-0.0.1.zip
Enter your PGXN username: guedes
Enter your PGXN password: ******
Trying to release my_cool_extension-0.0.1.zip ... released successfully!
View
5 lib/pgxn_utils/cli.rb
@@ -7,7 +7,6 @@ class CLI < Thor
include Thor::Actions
include PgxnUtils::NoTasks
- include Grit
desc "skeleton extension_name", "Creates an extension skeleton in current directory"
@@ -31,7 +30,7 @@ def skeleton(extension_name,target=nil)
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 @@ def skeleton(extension_name,target=nil)
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
View
22 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
View
5 spec/cli_spec.rb
@@ -2,12 +2,7 @@
describe PgxnUtils::CLI do
- before(:all) do
- system "mv META.json meta.json"
- end
-
after(:all) do
- system "mv meta.json META.json"
system "rm -rf /tmp/extension.*"
system "rm -rf extension.*"
end

0 comments on commit 9ec50ee

Please sign in to comment.
Something went wrong with that request. Please try again.