Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'release-1.0.2'

  • Loading branch information...
commit 27afa7ce172ecc2b44bbda855e6caca1d6c7f7c1 2 parents d75ad82 + 48f34b3
@jeffWelling jeffWelling authored
View
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+*.swp
+rdoc/
+pkg/
View
32 Rakefile
@@ -0,0 +1,32 @@
+require 'rubygems'
+require 'rake'
+require 'rake/clean'
+require 'rake/rdoctask'
+require 'rspec/core/rake_task'
+
+CLEAN.include('**/*.gem')
+
+desc "Creates the TicGit-ng gem"
+task :create_gem => [:clean] do
+ spec = eval(IO.read('ticgit-ng.gemspec'))
+ gem = Gem::Builder.new(spec).build
+ Dir.mkdir("pkg") unless Dir.exists? "pkg"
+ FileUtils.mv("#{File.dirname(__FILE__)}/#{gem}", "pkg")
+end
+
+desc "Runs spec suite"
+RSpec::Core::RakeTask.new(:spec) do |spec|
+ spec.pattern = 'spec/*_spec.rb'
+ spec.rspec_opts = ['--backtrace --colour']
+end
+
+desc "Creates rdoc documentation"
+Rake::RDocTask.new do |rdoc|
+ version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = "TicGit-ng #{version}"
+ rdoc.rdoc_files.include('README*')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+task :default => :create_gem
View
21 lib/ticgit-ng.rb
@@ -13,9 +13,28 @@
require 'rubygems'
# requires git >= 1.0.5
require 'git'
+
+#Only redefine if we are not using 1.9
+unless Config::CONFIG["ruby_version"][/^\d\.9/]
+ # FIXME: Monkeypatch git until fixed upstream
+ module Git
+ class Lib
+ def config_get(name)
+ do_get = lambda do |name|
+ command('config', ['--get', name])
+ end
+ if @git_dir
+ Dir.chdir(@git_dir, &do_get)
+ else
+ build_list.call
+ end
+ end
+ end
+ end
+end
+
require 'ticgit-ng/base'
require 'ticgit-ng/cli'
-
module TicGitNG
autoload :VERSION, 'ticgit-ng/version'
autoload :Comment, 'ticgit-ng/comment'
View
22 lib/ticgit-ng/base.rb
@@ -205,10 +205,10 @@ def ticket_recent(ticket_id = nil)
def ticket_revparse(ticket_id)
if ticket_id
ticket_id = ticket_id.strip
-
+
if /^[0-9]*$/ =~ ticket_id
if t = @last_tickets[ticket_id.to_i - 1]
- return t
+ return t
end
else # partial or full sha
regex = /^#{Regexp.escape(ticket_id)}/
@@ -281,15 +281,15 @@ def sync_tickets(repo='origin', push=true, verbose=true )
puts "Fetching #{repo}" if verbose
@git.fetch(repo)
puts "Syncing tickets with #{repo}" if verbose
- remote_branches=@git.branches.remote.map{|b|
- b.full.gsub('remotes/', '')[Regexp.new("^#{Regexp.escape(repo)}/.*")]
+ remote_branches=@git.branches.remote.map{|b|
+ b.full.gsub('remotes/', '')[Regexp.new("^#{Regexp.escape(repo)}/.*")]
}.compact
remote_branches.include?("#{repo}/ticgit-ng") ? r_ticgit='ticgit-ng' : r_ticgit='ticgit'
- in_branch(false) do
- repo_g=git.remote(repo)
- git.pull(repo_g, repo+'/'+r_ticgit)
- git.push(repo_g, "#{which_branch?}:"+r_ticgit ) if push
- puts "Tickets synchronized." if verbose
+ in_branch(false) do
+ repo_g=git.remote(repo)
+ git.pull(repo_g, repo+'/'+r_ticgit)
+ git.push(repo_g, "#{which_branch?}:"+r_ticgit ) if push
+ puts "Tickets synchronized." if verbose
end
end
@@ -302,7 +302,7 @@ def read_tickets
bs = git.lib.branches_all.map{|b| b.first }
- unless (bs.include?(which_branch?) || bs.include?(which_branch?)) &&
+ unless (bs.include?(which_branch?) || bs.include?(which_branch?)) &&
File.directory?(@tic_working)
init_ticgitng_branch(bs.include?(which_branch?))
end
@@ -356,7 +356,7 @@ def in_branch(branch_exists = true)
git.lib.change_head_branch(which_branch?)
git.with_index(@tic_index) do
git.with_working(@tic_working) do |wd|
- git.lib.checkout(which_branch?) if needs_checkout &&
+ git.lib.checkout(which_branch?) if needs_checkout &&
branch_exists
yield wd
end
View
5 lib/ticgit-ng/cli.rb
@@ -78,8 +78,9 @@ def usage(args = nil)
end
end
- def get_editor_message(message_file = nil)
- message_file = Tempfile.new('ticgitng_message').path if !message_file
+ def get_editor_message(comments = nil)
+ message_file = Tempfile.new('ticgitng_message').path
+ File.open(message_file, 'w') { |f| f.puts comments } if comments
editor = ENV["EDITOR"] || 'vim'
system("#{editor} #{message_file}");
View
2  lib/ticgit-ng/command/comment.rb
@@ -27,7 +27,7 @@ def execute
elsif file
tic.ticket_comment(File.read(file), tid)
else
- return unless message = get_editor_message
+ return unless message = get_editor_message(tic)
tic.ticket_comment(message.join(''), tid)
end
end
View
13 lib/ticgit-ng/command/new.rb
@@ -13,14 +13,11 @@ def execute
ticket_show(tic.ticket_new(title, options.to_hash))
else
# interactive
- message_file = Tempfile.new('ticgit_message').path
- File.open(message_file, 'w') do |f|
- f.puts "\n# ---"
- f.puts "tags:"
- f.puts "# first line will be the title of the tic, the rest will be the first comment"
- f.puts "# if you would like to add initial tags, put them on the 'tags:' line, comma delim"
- end
- if message = get_editor_message(message_file)
+ comment = "\n# ---\ntags:\n"
+ comment += "# first line will be the title of the tic, the rest will be the first comment\n"
+ comment += "# if you would like to add initial tags, put them on the 'tags:' line, comma delim"
+
+ if message = get_editor_message(comment)
title = message.shift
if title && title.chomp.length > 0
title = title.chomp
View
10 lib/ticgit-ng/ticket.rb
@@ -7,8 +7,14 @@ class Ticket
attr_accessor :comments, :tags, :attachments # arrays
def initialize(base, options = {})
- options[:user_name] ||= base.git.config('user.name')
- options[:user_email] ||= base.git.config('user.email')
+ # FIXME: what/where/who/how changed config to hash?
+ if (cfg = base.git.config).is_a? Hash
+ options[:user_name] ||= cfg["user.name"]
+ options[:user_email] ||= cfg["user.email"]
+ else
+ options[:user_name] ||= cfg("user.name")
+ options[:user_email] ||= cfg("user.email")
+ end
@base = base
@opts = options || {}
View
2  lib/ticgit-ng/version.rb
@@ -1,3 +1,3 @@
module TicGitNG
- VERSION = '1.0.1.3'
+ VERSION = '1.0.2'
end
View
8 spec/base_spec.rb
@@ -45,6 +45,14 @@
tic.state.should_not eql('resolve')
end
+ describe "Testing a ticket" do
+ let(:tic) { @ticgitng.ticket_list.first }
+
+ it "should get username from git" do
+ tic.opts.should be_a Hash
+ end
+ end
+
it "should be able to change to whom the ticket is assigned" do
tic = @ticgitng.ticket_list.first
@ticgitng.ticket_assign('pope', tic.ticket_id)
View
20 spec/cli_spec.rb
@@ -23,22 +23,22 @@
Please specify at least one action to execute.
Usage: ti COMMAND [FLAGS] [ARGS]
-
+
The available ticgit commands are:
- recent List recent activities
+ assign Assings a ticket to someone
+ attach Attach file to ticket
checkout Checkout a ticket
- tag Modify tags of a ticket
comment Comment on a ticket
+ list List tickets
milestone List and modify milestones
- assign Assings a ticket to someone
- sync Sync tickets
+ new Create a new ticket
points Assign points to a ticket
- state Change state of a ticket
+ recent List recent activities
show Show a ticket
- new Create a new ticket
- attach Attach file to ticket
- list List tickets
-
+ state Change state of a ticket
+ tag Modify tags of a ticket
+ sync Sync tickets
+
Common options:
-v, --version Show the version number
-h, --help Display this help
Please sign in to comment.
Something went wrong with that request. Please try again.