gitcycle 0.2.25 → 0.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -66,31 +66,4 @@ Scenario: Change source branch
66
66
  Pushing 'origin/master-ticket.id'.
67
67
  Sending branch information to gitcycle.
68
68
  """
69
- And redis entries valid
70
-
71
- Scenario: Collaborator
72
- Given a fresh set of repositories
73
- When I cd to the owner repo
74
- And I create a new branch "some_branch"
75
- And I checkout some_branch
76
- And I push some_branch
77
- And I cd to the user repo
78
- And I execute gitcycle branch with a new URL or string
79
- And I enter "n"
80
- And I enter "config.owner/some_branch"
81
- And I enter "y"
82
- And gitcycle runs
83
- Then output includes
84
- """
85
- Your work will eventually merge into 'master'. Is this correct? (y/n)
86
- What branch would you like to eventually merge into?
87
- Retrieving branch information from gitcycle.
88
- Would you like to name your branch 'ticket.id'? (y/n)
89
- Adding remote repo 'config.owner/config.repo'.
90
- Fetching remote 'config.owner'.
91
- Checking out remote branch 'ticket.id' from 'config.owner/config.repo/some_branch'.
92
- Fetching remote 'origin'.
93
- Pushing 'origin/ticket.id'.
94
- Sending branch information to gitcycle.
95
- """
96
69
  And redis entries valid
@@ -56,27 +56,4 @@ Scenario: Reopen pull request
56
56
  """
57
57
  And output includes "Opening issue" with URL
58
58
  And URL is a valid issue
59
- And URL is not the same as the last
60
-
61
- Scenario: Collaborator
62
- Given a fresh set of repositories
63
- When I cd to the owner repo
64
- And I create a new branch "some_branch"
65
- And I checkout some_branch
66
- And I push some_branch
67
- And I cd to the user repo
68
- And I execute gitcycle branch with a new URL or string
69
- And I enter "n"
70
- And I enter "config.owner/some_branch"
71
- And I enter "y"
72
- And gitcycle runs
73
- And I commit something
74
- And I execute gitcycle with "ready"
75
- And gitcycle runs
76
- Then output includes
77
- """
78
- Retrieving branch information from gitcycle.
79
- Fetching remote 'config.owner'.
80
- Merging remote branch 'some_branch' from 'config.owner/gitcycle_test'.
81
- Pushing branch 'config.owner/some_branch'.
82
- """
59
+ And URL is not the same as the last
data/gitcycle.gemspec CHANGED
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "gitcycle"
9
- s.version = '0.2.25'
9
+ s.version = '0.2.26'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ 'Winton Welsh' ]
12
12
  s.email = [ 'mail@wintoni.us' ]
data/lib/gitcycle.rb CHANGED
@@ -72,10 +72,6 @@ class Gitcycle
72
72
  end
73
73
 
74
74
  source = params['branch[source]']
75
- if source.include?('/')
76
- params['branch[home]'], params['branch[source]'] = source.split('/')
77
- params['branch[collab]'] = 1
78
- end
79
75
 
80
76
  puts "\nRetrieving branch information from gitcycle.\n".green
81
77
  branch = get('branch', params)
@@ -91,7 +87,7 @@ class Gitcycle
91
87
  end
92
88
 
93
89
  checkout_remote_branch(
94
- :owner => branch['collab'] ? branch['home'] : owner,
90
+ :owner => owner,
95
91
  :repo => repo,
96
92
  :branch => branch['source'],
97
93
  :target => name
@@ -145,11 +141,12 @@ class Gitcycle
145
141
  remote = repo['owner'] unless collab
146
142
 
147
143
  output = add_remote_and_fetch(
144
+ :catch => false,
148
145
  :owner => remote,
149
146
  :repo => @git_repo
150
147
  )
151
148
 
152
- if output.include?('ERROR')
149
+ if errored?(output)
153
150
  og_remote = remote
154
151
  remote = repo["owner"]
155
152
 
@@ -160,9 +157,9 @@ class Gitcycle
160
157
  end
161
158
 
162
159
  puts "Creating branch '#{branch}' from '#{remote}/#{branch}'.\n".green
163
- output = run("git branch --no-track #{branch} #{remote}/#{branch}")
160
+ output = run("git branch --no-track #{branch} #{remote}/#{branch}", :catch => false)
164
161
 
165
- if output.include?("fatal")
162
+ if errored?(output)
166
163
  puts "Could not find branch #{"'#{og_remote}/#{branch}' or " if og_remote}'#{remote}/#{branch}'.\n".red
167
164
  exit
168
165
  end
@@ -542,7 +539,7 @@ class Gitcycle
542
539
  end
543
540
 
544
541
  puts "Fetching remote '#{owner}'.\n".green
545
- run("git fetch -q #{owner}")
542
+ run("git fetch -q #{owner}", :catch => options[:catch])
546
543
  end
547
544
  end
548
545
 
@@ -581,12 +578,12 @@ class Gitcycle
581
578
 
582
579
  if branches(:match => target)
583
580
  if yes?("You already have a branch called '#{target}'. Overwrite?")
584
- run_safe("git push origin :#{target} -q")
585
- run_safe("git checkout master -q")
586
- run_safe("git branch -D #{target}")
581
+ run("git push origin :#{target} -q")
582
+ run("git checkout master -q")
583
+ run("git branch -D #{target}")
587
584
  else
588
- run_safe("git checkout #{target} -q")
589
- run_safe("git pull origin #{target} -q")
585
+ run("git checkout #{target} -q")
586
+ run("git pull origin #{target} -q")
590
587
  return
591
588
  end
592
589
  end
@@ -714,6 +711,10 @@ class Gitcycle
714
711
  end
715
712
  end
716
713
 
714
+ def errored?(output)
715
+ output.include?("fatal: ") || output.include?("ERROR: ") || $?.exitstatus != 0
716
+ end
717
+
717
718
  def exec_git(command, args)
718
719
  args.unshift("git", command)
719
720
  Kernel.exec(*args.collect(&:to_s))
@@ -829,6 +830,11 @@ class Gitcycle
829
830
  b
830
831
  end
831
832
  end
833
+
834
+ def q(question, extra='')
835
+ puts "#{question.yellow}#{extra}"
836
+ $input ? $input.shift : $stdin.gets.strip
837
+ end
832
838
 
833
839
  def require_config
834
840
  unless @login && @token
@@ -837,6 +843,7 @@ class Gitcycle
837
843
  puts "Have you set up this repository at http://gitcycle.com?\n".yellow
838
844
  exit
839
845
  end
846
+ true
840
847
  end
841
848
 
842
849
  def require_git
@@ -845,34 +852,30 @@ class Gitcycle
845
852
  puts "Are you sure you are in a git repository?\n".yellow
846
853
  exit
847
854
  end
855
+ true
848
856
  end
849
857
 
850
- def save_config
851
- FileUtils.mkdir_p(File.dirname(@config_path))
852
- File.open(@config_path, 'w') do |f|
853
- f.write(YAML.dump(@config))
854
- end
855
- end
856
-
857
- def q(question, extra='')
858
- puts "#{question.yellow}#{extra}"
859
- $input ? $input.shift : $stdin.gets.strip
860
- end
861
-
862
- def run(cmd)
858
+ def run(cmd, options={})
863
859
  if ENV['RUN'] == '0'
864
860
  puts cmd
865
861
  else
866
- `#{cmd} 2>&1`
862
+ output = `#{cmd} 2>&1`
867
863
  end
868
- end
869
-
870
- def run_safe(cmd)
871
- run(cmd)
872
- if $? != 0
873
- puts "The last command was supposed to run without error, but it didn't :(\n".red
864
+ if options[:catch] != false && errored?(output)
865
+ puts "#{output}\n\n"
866
+ puts "Gitcycle encountered an error when running the last command:".red
867
+ puts " #{cmd}\n"
874
868
  puts "Please copy this session's output and send it to gitcycle@bleacherreport.com.\n".yellow
875
869
  exit
870
+ else
871
+ output
872
+ end
873
+ end
874
+
875
+ def save_config
876
+ FileUtils.mkdir_p(File.dirname(@config_path))
877
+ File.open(@config_path, 'w') do |f|
878
+ f.write(YAML.dump(@config))
876
879
  end
877
880
  end
878
881
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitcycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.25
4
+ version: 0.2.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
12
+ date: 2012-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber