hustle_and_flow 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +192 -16
  3. data/bin/hustle +4 -0
  4. data/lib/hustle_and_flow/binary/runner.rb +8 -4
  5. data/lib/hustle_and_flow/commands/start.rb +18 -19
  6. data/lib/hustle_and_flow/issue_tracker.rb +7 -6
  7. data/lib/hustle_and_flow/issue_trackers/commands/start.rb +17 -0
  8. data/lib/hustle_and_flow/issue_trackers/github/commands/start.rb +99 -0
  9. data/lib/hustle_and_flow/issue_trackers/github/issue.rb +8 -8
  10. data/lib/hustle_and_flow/issue_trackers/github/issues.rb +24 -46
  11. data/lib/hustle_and_flow/issue_trackers/github/tracker.rb +63 -0
  12. data/lib/hustle_and_flow/version.rb +1 -1
  13. data/lib/hustle_and_flow/version_control.rb +19 -0
  14. data/lib/hustle_and_flow/version_controls/commands/start.rb +17 -0
  15. data/lib/hustle_and_flow/{version_control → version_controls}/git/branch.rb +1 -1
  16. data/lib/hustle_and_flow/{version_control → version_controls}/git/branches.rb +8 -2
  17. data/lib/hustle_and_flow/version_controls/git/commands/start.rb +67 -0
  18. data/lib/hustle_and_flow/version_controls/git/repository.rb +70 -0
  19. data/spec/lib/hustle_and_flow/issue_trackers/github/issue_spec.rb +3 -3
  20. data/spec/lib/hustle_and_flow/issue_trackers/github/issues_spec.rb +3 -3
  21. data/spec/lib/hustle_and_flow/issue_trackers/{github_spec.rb → github/tracker_spec.rb} +6 -4
  22. data/spec/lib/hustle_and_flow/vcs_repository_spec.rb +3 -3
  23. data/spec/lib/hustle_and_flow/{version_control → version_controls}/git/branch_spec.rb +2 -2
  24. data/spec/lib/hustle_and_flow/{version_control → version_controls}/git/branches_spec.rb +2 -2
  25. data/spec/lib/hustle_and_flow/{version_control → version_controls}/git/repository_spec.rb +2 -2
  26. data/spec/support/git_repo.rb +4 -4
  27. metadata +20 -16
  28. data/lib/hustle_and_flow/issue_trackers/github.rb +0 -71
  29. data/lib/hustle_and_flow/vcs_repository.rb +0 -19
  30. data/lib/hustle_and_flow/version_control/git/repository.rb +0 -99
@@ -1,3 +1,3 @@
1
1
  module HustleAndFlow
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'hustle_and_flow/version_controls/git/repository'
2
+
3
+ module HustleAndFlow
4
+ class VersionControl
5
+ attr_accessor :adapter
6
+
7
+ def initialize(path:)
8
+ self.adapter = self.class.detect.new(path: path)
9
+ end
10
+
11
+ def self.detect
12
+ ::HustleAndFlow::VersionControls::Git::Repository
13
+ end
14
+
15
+ def method_missing(name, *args)
16
+ adapter.public_send(name, *args)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'hustle_and_flow/version_control'
2
+ require 'hustle_and_flow/version_controls/git/commands/start'
3
+
4
+ module HustleAndFlow
5
+ module VersionControls
6
+ module Commands
7
+ class Start
8
+ def self.call(**args)
9
+ version_controls_class = VersionControl.detect.name.gsub('::Repository', '')
10
+ command_class = const_get("::#{version_controls_class}::Commands::Start")
11
+
12
+ command_class.call(**args)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  module HustleAndFlow
2
- module VersionControl
2
+ module VersionControls
3
3
  module Git
4
4
  class Branch
5
5
  attr_accessor :repo,
@@ -1,8 +1,8 @@
1
1
  require 'hustle_and_flow/utils/url_slug'
2
- require 'hustle_and_flow/version_control/git/branch'
2
+ require 'hustle_and_flow/version_controls/git/branch'
3
3
 
4
4
  module HustleAndFlow
5
- module VersionControl
5
+ module VersionControls
6
6
  module Git
7
7
  class Branches
8
8
  include Enumerable
@@ -35,6 +35,12 @@ class Branches
35
35
  template.sub('*****', next_version_number.to_s)
36
36
  end
37
37
 
38
+ def create_next_branch(template:)
39
+ branch_name = next_branch_name(template: template)
40
+
41
+ repo.find_or_create_branch(branch_name)
42
+ end
43
+
38
44
  def selectable
39
45
  tracking_branches = branches.map do |branch|
40
46
  branch.name if branch.has_tracking_branch?
@@ -0,0 +1,67 @@
1
+ require 'hustle_and_flow/version_controls/git/branches'
2
+ require 'hustle_and_flow/formatters/branch_table_formatter'
3
+
4
+ module HustleAndFlow
5
+ module VersionControls
6
+ module Git
7
+ module Commands
8
+ class Start
9
+ attr_accessor :repo,
10
+ :io,
11
+ :number,
12
+ :title,
13
+ :branch_template
14
+
15
+ def initialize(**args)
16
+ self.repo = args[:repo]
17
+ self.io = args[:io]
18
+ self.number = args[:number]
19
+ self.title = args[:title]
20
+ self.branch_template = args[:branch_template]
21
+ end
22
+
23
+ def call
24
+ available_branches = repo.
25
+ branches.
26
+ selectable.
27
+ filter_by_issue(number: number,
28
+ title: title)
29
+
30
+ next_branch_name = available_branches.next_branch_name(template: branch_template)
31
+
32
+ selected = if available_branches.count.zero?
33
+ available_branches.create_next_branch(template: branch_template)
34
+ else
35
+ branch_number = nil
36
+
37
+ io.print_formatted_table \
38
+ title: 'Possible Existing Branches',
39
+ data: Formatters::BranchTableFormatter.new(available_branches).
40
+ to_ary
41
+
42
+ io.print_new_branch_prompt(next_branch_name)
43
+
44
+ until branch_number == 'c' ||
45
+ available_branches.valid_number?(branch_number)
46
+
47
+ branch_number = io.choose_branch
48
+ end
49
+
50
+ if branch_number == 'c'
51
+ available_branches.create_next_branch(template: branch_template)
52
+ else
53
+ available_branches.from_number(branch_number)
54
+ end
55
+ end
56
+
57
+ selected.start
58
+ end
59
+
60
+ def self.call(**args)
61
+ new(**args).call
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,70 @@
1
+ require 'git'
2
+
3
+ module HustleAndFlow
4
+ module VersionControls
5
+ module Git
6
+ class Repository
7
+ attr_accessor :repo
8
+
9
+ def initialize(path:)
10
+ self.repo = ::Git.open(path)
11
+ end
12
+
13
+ def user
14
+ repo.config('github.user')
15
+ end
16
+
17
+ def base_name
18
+ origin_url[%r{github\.com.([\w\-]+/[\w\-]+)}, 1]
19
+ end
20
+
21
+ def upstream_remote_for_branch(branch_name, value = nil)
22
+ repo.config(upstream_remote_config_key(branch_name), value)
23
+ end
24
+
25
+ def upstream_branch_for_branch(branch_name, value = nil)
26
+ repo.config(upstream_merge_config_key(branch_name), value)
27
+ end
28
+
29
+ def with_branch(branch_name)
30
+ repo.checkout(branch_name)
31
+
32
+ yield
33
+
34
+ repo.push('origin', branch_name)
35
+ end
36
+
37
+ def find_or_create_branch(branch_name)
38
+ new_branch = repo.branch(branch_name)
39
+ new_branch.checkout
40
+
41
+ Branch.new(repo: self,
42
+ branch: new_branch)
43
+ end
44
+
45
+ def branches
46
+ Branches.new(repo: self,
47
+ branches: repo.branches)
48
+ end
49
+
50
+ private
51
+
52
+ def origin_url
53
+ origin.url
54
+ end
55
+
56
+ def origin
57
+ @origin ||= repo.remote('origin')
58
+ end
59
+
60
+ def upstream_remote_config_key(branch_name)
61
+ "branch.#{branch_name}.remote"
62
+ end
63
+
64
+ def upstream_merge_config_key(branch_name)
65
+ "branch.#{branch_name}.merge"
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,14 +1,14 @@
1
1
  require 'rspectacular'
2
2
  require 'octokit'
3
- require 'hustle_and_flow/issue_trackers/github'
3
+ require 'hustle_and_flow/issue_trackers/github/tracker'
4
4
  require 'hustle_and_flow/issue_trackers/github/issue'
5
5
 
6
6
  module HustleAndFlow
7
7
  module IssueTrackers
8
- class Github
8
+ module Github
9
9
  describe Issue, vcr: { record: :all } do
10
10
  let(:repo) { OpenStruct.new(base_name: 'thekompanee/hustle_and_flow') }
11
- let(:tracker) { Github.new(repo: repo) }
11
+ let(:tracker) { Tracker.new(repo: repo) }
12
12
 
13
13
  it 'can create an issue' do
14
14
  issue = Issue.create(tracker: tracker,
@@ -1,13 +1,13 @@
1
1
  require 'spec_helper'
2
- require 'hustle_and_flow/issue_trackers/github'
2
+ require 'hustle_and_flow/issue_trackers/github/tracker'
3
3
  require 'hustle_and_flow/issue_trackers/github/issues'
4
4
 
5
5
  module HustleAndFlow
6
6
  module IssueTrackers
7
- class Github
7
+ module Github
8
8
  describe Issues, vcr: { record: :all } do
9
9
  let(:repo) { OpenStruct.new(base_name: 'thekompanee/hustle_and_flow') }
10
- let(:tracker) { Github.new(repo: repo) }
10
+ let(:tracker) { Tracker.new(repo: repo) }
11
11
 
12
12
  it 'can find an issue based on the type and title' do
13
13
  issue = Issues.new(tracker: tracker).
@@ -1,11 +1,12 @@
1
1
  require 'rspectacular'
2
- require 'hustle_and_flow/issue_trackers/github'
2
+ require 'hustle_and_flow/issue_trackers/github/tracker'
3
3
 
4
4
  module HustleAndFlow
5
5
  module IssueTrackers
6
- describe Github, :vcr do
6
+ module Github
7
+ describe Tracker, :vcr do
7
8
  let(:repo) { OpenStruct.new(base_name: 'thekompanee/hustle_and_flow') }
8
- let(:tracker) { Github.new(repo: repo) }
9
+ let(:tracker) { Tracker.new(repo: repo) }
9
10
 
10
11
  it 'can find a list of issues' do
11
12
  issues = tracker.find_issues_by(status: 'open')
@@ -42,10 +43,11 @@ describe Github, :vcr do
42
43
  issue = tracker.find_or_create_issue type: 'feature',
43
44
  title: 'Ninjitsu'
44
45
 
45
- assigned_issue = Github.assign_issue(issue, to: 'jfelchner')
46
+ assigned_issue = Tracker.assign_issue(issue, to: 'jfelchner')
46
47
 
47
48
  expect(assigned_issue).to be_assigned_to 'jfelchner'
48
49
  end
49
50
  end
50
51
  end
51
52
  end
53
+ end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
- require 'hustle_and_flow/vcs_repository'
2
+ require 'hustle_and_flow/version_control'
3
3
 
4
4
  module HustleAndFlow
5
- describe VcsRepository do
5
+ describe VersionControl do
6
6
  it 'can determine the base name of the repo' do
7
7
  with_repo do |git|
8
8
  git.source.add_remote('origin', 'https://github.com/thekompanee/hustle_and_flow.git')
9
- repo = VcsRepository.new(path: git.source.dir.to_s)
9
+ repo = VersionControl.new(path: git.source.dir.to_s)
10
10
 
11
11
  expect(repo.base_name).to eql 'thekompanee/hustle_and_flow'
12
12
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
- require 'hustle_and_flow/version_control/git/branch'
2
+ require 'hustle_and_flow/version_controls/git/branch'
3
3
 
4
4
  module HustleAndFlow
5
- module VersionControl
5
+ module VersionControls
6
6
  module Git
7
7
  describe Branch do
8
8
  it 'knows if it is the current branch' do
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
- require 'hustle_and_flow/version_control/git/branches'
2
+ require 'hustle_and_flow/version_controls/git/branches'
3
3
  require 'hustle_and_flow/issue_trackers/github/issue'
4
4
 
5
5
  module HustleAndFlow
6
- module VersionControl
6
+ module VersionControls
7
7
  module Git
8
8
  describe Branches do
9
9
  it 'can filter a list of branches by an issue number' do
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
- require 'hustle_and_flow/version_control/git/repository'
2
+ require 'hustle_and_flow/version_controls/git/repository'
3
3
 
4
4
  module HustleAndFlow
5
- module VersionControl
5
+ module VersionControls
6
6
  module Git
7
7
  describe Repository do
8
8
  # it 'can determine the base name of the repo' do
@@ -1,5 +1,5 @@
1
1
  require 'fileutils'
2
- require 'hustle_and_flow/version_control/git/repository'
2
+ require 'hustle_and_flow/version_controls/git/repository'
3
3
 
4
4
  def with_repo
5
5
  name = 'my-repo'
@@ -12,7 +12,7 @@ def with_repo
12
12
  my_repo.add(all: true)
13
13
  my_repo.commit_all('Initial commit')
14
14
 
15
- repo = HustleAndFlow::VersionControl::Git::Repository.new(path: Dir.pwd)
15
+ repo = HustleAndFlow::VersionControls::Git::Repository.new(path: Dir.pwd)
16
16
 
17
17
  yield repo if block_given?
18
18
  end
@@ -31,13 +31,13 @@ def with_remote_repo
31
31
  my_repo.commit_all('Initial commit')
32
32
  end
33
33
 
34
- remote_repo = HustleAndFlow::VersionControl::Git::Repository.new(path: remote_directory)
34
+ remote_repo = HustleAndFlow::VersionControls::Git::Repository.new(path: remote_directory)
35
35
 
36
36
  Dir.chdir local_directory do
37
37
  Git.clone(remote_directory, name)
38
38
  end
39
39
 
40
- local_repo = HustleAndFlow::VersionControl::Git::Repository.new(path: "#{local_directory}/#{name}")
40
+ local_repo = HustleAndFlow::VersionControls::Git::Repository.new(path: "#{local_directory}/#{name}")
41
41
 
42
42
  yield [local_repo, remote_repo] if block_given?
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hustle_and_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - thekompanee
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-06 00:00:00.000000000 Z
12
+ date: 2014-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit
@@ -173,16 +173,20 @@ files:
173
173
  - lib/hustle_and_flow/formatters/issue_table_formatter.rb
174
174
  - lib/hustle_and_flow/io/shell.rb
175
175
  - lib/hustle_and_flow/issue_tracker.rb
176
- - lib/hustle_and_flow/issue_trackers/github.rb
176
+ - lib/hustle_and_flow/issue_trackers/commands/start.rb
177
+ - lib/hustle_and_flow/issue_trackers/github/commands/start.rb
177
178
  - lib/hustle_and_flow/issue_trackers/github/issue.rb
178
179
  - lib/hustle_and_flow/issue_trackers/github/issues.rb
180
+ - lib/hustle_and_flow/issue_trackers/github/tracker.rb
179
181
  - lib/hustle_and_flow/utils/string.rb
180
182
  - lib/hustle_and_flow/utils/url_slug.rb
181
- - lib/hustle_and_flow/vcs_repository.rb
182
183
  - lib/hustle_and_flow/version.rb
183
- - lib/hustle_and_flow/version_control/git/branch.rb
184
- - lib/hustle_and_flow/version_control/git/branches.rb
185
- - lib/hustle_and_flow/version_control/git/repository.rb
184
+ - lib/hustle_and_flow/version_control.rb
185
+ - lib/hustle_and_flow/version_controls/commands/start.rb
186
+ - lib/hustle_and_flow/version_controls/git/branch.rb
187
+ - lib/hustle_and_flow/version_controls/git/branches.rb
188
+ - lib/hustle_and_flow/version_controls/git/commands/start.rb
189
+ - lib/hustle_and_flow/version_controls/git/repository.rb
186
190
  - spec/lib/hustle_and_flow/formatters/branch_table_formatter_spec.rb
187
191
  - spec/lib/hustle_and_flow/formatters/issue_detail_formatter_spec.rb
188
192
  - spec/lib/hustle_and_flow/formatters/issue_table_formatter_spec.rb
@@ -190,11 +194,11 @@ files:
190
194
  - spec/lib/hustle_and_flow/issue_tracker_spec.rb
191
195
  - spec/lib/hustle_and_flow/issue_trackers/github/issue_spec.rb
192
196
  - spec/lib/hustle_and_flow/issue_trackers/github/issues_spec.rb
193
- - spec/lib/hustle_and_flow/issue_trackers/github_spec.rb
197
+ - spec/lib/hustle_and_flow/issue_trackers/github/tracker_spec.rb
194
198
  - spec/lib/hustle_and_flow/vcs_repository_spec.rb
195
- - spec/lib/hustle_and_flow/version_control/git/branch_spec.rb
196
- - spec/lib/hustle_and_flow/version_control/git/branches_spec.rb
197
- - spec/lib/hustle_and_flow/version_control/git/repository_spec.rb
199
+ - spec/lib/hustle_and_flow/version_controls/git/branch_spec.rb
200
+ - spec/lib/hustle_and_flow/version_controls/git/branches_spec.rb
201
+ - spec/lib/hustle_and_flow/version_controls/git/repository_spec.rb
198
202
  - spec/lib/utils/url_slug_spec.rb
199
203
  - spec/spec_helper.rb
200
204
  - spec/support/git_repo.rb
@@ -220,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
224
  version: '0'
221
225
  requirements: []
222
226
  rubyforge_project:
223
- rubygems_version: 2.3.0
227
+ rubygems_version: 2.2.2
224
228
  signing_key:
225
229
  specification_version: 4
226
230
  summary: Development Workflow Commands
@@ -232,11 +236,11 @@ test_files:
232
236
  - spec/lib/hustle_and_flow/issue_tracker_spec.rb
233
237
  - spec/lib/hustle_and_flow/issue_trackers/github/issue_spec.rb
234
238
  - spec/lib/hustle_and_flow/issue_trackers/github/issues_spec.rb
235
- - spec/lib/hustle_and_flow/issue_trackers/github_spec.rb
239
+ - spec/lib/hustle_and_flow/issue_trackers/github/tracker_spec.rb
236
240
  - spec/lib/hustle_and_flow/vcs_repository_spec.rb
237
- - spec/lib/hustle_and_flow/version_control/git/branch_spec.rb
238
- - spec/lib/hustle_and_flow/version_control/git/branches_spec.rb
239
- - spec/lib/hustle_and_flow/version_control/git/repository_spec.rb
241
+ - spec/lib/hustle_and_flow/version_controls/git/branch_spec.rb
242
+ - spec/lib/hustle_and_flow/version_controls/git/branches_spec.rb
243
+ - spec/lib/hustle_and_flow/version_controls/git/repository_spec.rb
240
244
  - spec/lib/utils/url_slug_spec.rb
241
245
  - spec/spec_helper.rb
242
246
  - spec/support/git_repo.rb
@@ -1,71 +0,0 @@
1
- require 'octokit'
2
- require 'hustle_and_flow/issue_trackers/github/issue'
3
- require 'hustle_and_flow/issue_trackers/github/issues'
4
-
5
- module HustleAndFlow
6
- module IssueTrackers
7
- class Github
8
- attr_accessor :client,
9
- :repo,
10
- :source
11
-
12
- def initialize(repo:)
13
- Octokit.auto_paginate = true
14
-
15
- self.client = Octokit::Client.new(netrc: true)
16
- self.repo = repo
17
- end
18
-
19
- def repo_name
20
- repo.base_name
21
- end
22
-
23
- def start(io:, me:, issue_data:)
24
- Issues.start(tracker: self,
25
- io: io,
26
- me: me,
27
- issue_data: issue_data)
28
- end
29
-
30
- # def ready_for_review(branch)
31
- # #
32
- # # No issue number
33
- # # Find by title
34
- # # Has issue number
35
- # # Find by number
36
- # #
37
- # # Issue found
38
- # # Issue closed
39
- # # Ask to reopen issue
40
- # # Issue open
41
- # # Issue being reviewed
42
- # # Issue not being reviewed
43
- # # Issue not found
44
- # # Ask to create issue
45
- # #
46
- # # Lookup Pull Request from Issue and Version Number
47
- # #
48
- # # Pull Request Found
49
- # # How are PR's found?
50
- # #
51
- # # PR Title Format: #15 v1 - My Issue Title
52
- # #
53
- # # Pull Request Closed
54
- # # Reopen PR
55
- # # Pull Request Open
56
- # # Use found PR
57
- # # Pull Request Not Found
58
- # # Create New PR
59
- # #
60
- # pull_request = PullRequest.find_or_create_from_branch_name(branch.name)
61
- # issue = Issue.find_or_create_from_branch_name(branch.name)
62
- #
63
- # issue.ready_for_review(reviewer_names: branch.overwritten_authors)
64
- # end
65
- #
66
- # def update_pull_request(branch)
67
- # client.create_pull_request()
68
- # end
69
- end
70
- end
71
- end
@@ -1,19 +0,0 @@
1
- require 'hustle_and_flow/version_control/git/repository'
2
-
3
- module HustleAndFlow
4
- class VcsRepository
5
- attr_accessor :adapter
6
-
7
- def initialize(**args)
8
- self.adapter = HustleAndFlow::
9
- VersionControl::
10
- Git::
11
- Repository.
12
- new(path: args[:path])
13
- end
14
-
15
- def method_missing(name, *args)
16
- adapter.public_send(name, *args)
17
- end
18
- end
19
- end
@@ -1,99 +0,0 @@
1
- require 'git'
2
- require 'hustle_and_flow/version_control/git/branches'
3
- require 'hustle_and_flow/formatters/branch_table_formatter'
4
-
5
- module HustleAndFlow
6
- module VersionControl
7
- module Git
8
- class Repository
9
- attr_accessor :repo
10
-
11
- def initialize(path:)
12
- self.repo = ::Git.open(path)
13
- end
14
-
15
- def start(io:, number:, title:, branch_template:)
16
- available_branches = branches.
17
- selectable.
18
- filter_by_issue(number: number,
19
- title: title)
20
-
21
- next_branch_name = available_branches.next_branch_name(template: branch_template)
22
-
23
- selected = if available_branches.count.zero?
24
- Branch.new(repo: self, branch: repo.checkout(next_branch_name,
25
- new_branch: true))
26
- else
27
- branch_number = nil
28
-
29
- io.print_formatted_table \
30
- title: 'Possible Existing Branches',
31
- data: Formatters::BranchTableFormatter.new(available_branches).
32
- to_ary
33
-
34
- io.print_new_branch_prompt(next_branch_name)
35
-
36
- until available_branches.valid_number? branch_number
37
- branch_number = io.choose_branch
38
- end
39
-
40
- available_branches.from_number(branch_number)
41
- end
42
-
43
- selected.start
44
- end
45
-
46
- def user
47
- repo.config('github.user')
48
- end
49
-
50
- def base_name
51
- origin_url[%r{github\.com.([\w\-]+/[\w\-]+)}, 1]
52
- end
53
-
54
- def upstream_remote_for_branch(branch_name, value = nil)
55
- repo.config(upstream_remote_config_key(branch_name), value)
56
- end
57
-
58
- def upstream_branch_for_branch(branch_name, value = nil)
59
- repo.config(upstream_merge_config_key(branch_name), value)
60
- end
61
-
62
- def with_branch(branch_name)
63
- repo.checkout(branch_name)
64
-
65
- yield
66
-
67
- repo.push('origin', branch_name)
68
- end
69
-
70
- private
71
-
72
- def branches
73
- Branches.new(repo: self,
74
- branches: repo.branches)
75
- end
76
-
77
- def new_branch_name(branch_template)
78
- branch_template.sub('*****', branches.next_version_number)
79
- end
80
-
81
- def origin_url
82
- origin.url
83
- end
84
-
85
- def origin
86
- @origin ||= repo.remote('origin')
87
- end
88
-
89
- def upstream_remote_config_key(branch_name)
90
- "branch.#{branch_name}.remote"
91
- end
92
-
93
- def upstream_merge_config_key(branch_name)
94
- "branch.#{branch_name}.merge"
95
- end
96
- end
97
- end
98
- end
99
- end