git_reflow 0.8.9 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/multi-ruby-tests.yml +33 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -0
- data/Appraisals +1 -6
- data/CHANGELOG.md +466 -348
- data/Gemfile.lock +99 -72
- data/LICENSE +20 -20
- data/README.md +481 -0
- data/Rakefile +15 -8
- data/Workflow +3 -0
- data/_config.yml +1 -0
- data/bin/console +7 -7
- data/bin/setup +6 -6
- data/exe/git-reflow +20 -36
- data/git_reflow.gemspec +26 -30
- data/lib/git_reflow.rb +3 -15
- data/lib/git_reflow/config.rb +48 -13
- data/lib/git_reflow/git_helpers.rb +69 -22
- data/lib/git_reflow/git_server.rb +63 -63
- data/lib/git_reflow/git_server/base.rb +68 -68
- data/lib/git_reflow/git_server/bit_bucket.rb +101 -101
- data/lib/git_reflow/git_server/bit_bucket/pull_request.rb +84 -84
- data/lib/git_reflow/git_server/git_hub.rb +53 -41
- data/lib/git_reflow/git_server/git_hub/pull_request.rb +16 -14
- data/lib/git_reflow/git_server/pull_request.rb +4 -2
- data/lib/git_reflow/merge_error.rb +9 -9
- data/lib/git_reflow/rspec.rb +3 -2
- data/lib/git_reflow/rspec/command_line_helpers.rb +23 -6
- data/lib/git_reflow/rspec/stub_helpers.rb +13 -13
- data/lib/git_reflow/rspec/workflow_helpers.rb +18 -0
- data/lib/git_reflow/sandbox.rb +16 -6
- data/lib/git_reflow/version.rb +1 -1
- data/lib/git_reflow/workflow.rb +304 -9
- data/lib/git_reflow/workflows/FlatMergeWorkflow +38 -0
- data/lib/git_reflow/workflows/core.rb +364 -238
- data/spec/fixtures/authentication_failure.json +3 -0
- data/spec/fixtures/awesome_workflow.rb +3 -7
- data/spec/fixtures/git/git_config +7 -7
- data/spec/fixtures/issues/comment.json.erb +27 -27
- data/spec/fixtures/issues/comments.json +29 -29
- data/spec/fixtures/issues/comments.json.erb +15 -15
- data/spec/fixtures/pull_requests/comment.json.erb +45 -45
- data/spec/fixtures/pull_requests/comments.json +47 -47
- data/spec/fixtures/pull_requests/comments.json.erb +15 -15
- data/spec/fixtures/pull_requests/commits.json +29 -29
- data/spec/fixtures/pull_requests/external_pull_request.json +145 -145
- data/spec/fixtures/pull_requests/pull_request.json +142 -142
- data/spec/fixtures/pull_requests/pull_request.json.erb +142 -142
- data/spec/fixtures/pull_requests/pull_request_branch_nonexistent_error.json +32 -0
- data/spec/fixtures/pull_requests/pull_request_exists_error.json +32 -32
- data/spec/fixtures/pull_requests/pull_requests.json +136 -136
- data/spec/fixtures/repositories/commit.json +53 -53
- data/spec/fixtures/repositories/commit.json.erb +53 -53
- data/spec/fixtures/repositories/commits.json.erb +13 -13
- data/spec/fixtures/repositories/statuses.json +31 -31
- data/spec/fixtures/users/user.json +32 -0
- data/spec/lib/git_reflow/git_helpers_spec.rb +115 -12
- data/spec/lib/git_reflow/git_server/bit_bucket_spec.rb +81 -81
- data/spec/lib/git_reflow/git_server/git_hub/pull_request_spec.rb +10 -10
- data/spec/lib/git_reflow/git_server/git_hub_spec.rb +77 -3
- data/spec/lib/git_reflow/git_server/pull_request_spec.rb +9 -3
- data/spec/lib/git_reflow/git_server_spec.rb +101 -101
- data/spec/lib/git_reflow/sandbox_spec.rb +1 -1
- data/spec/lib/git_reflow/workflow_spec.rb +304 -59
- data/spec/lib/git_reflow/workflows/core_spec.rb +225 -67
- data/spec/lib/git_reflow/workflows/flat_merge_spec.rb +71 -59
- data/spec/lib/git_reflow_spec.rb +2 -25
- data/spec/spec_helper.rb +3 -0
- data/spec/support/fixtures.rb +54 -54
- data/spec/support/github_helpers.rb +99 -109
- data/spec/support/mock_pull_request.rb +17 -17
- data/spec/support/web_mocks.rb +39 -39
- metadata +51 -74
- data/README.rdoc +0 -461
- data/circle.yml +0 -26
- data/lib/git_reflow/commands/deliver.rb +0 -10
- data/lib/git_reflow/commands/refresh.rb +0 -20
- data/lib/git_reflow/commands/review.rb +0 -13
- data/lib/git_reflow/commands/setup.rb +0 -11
- data/lib/git_reflow/commands/stage.rb +0 -9
- data/lib/git_reflow/commands/start.rb +0 -18
- data/lib/git_reflow/commands/status.rb +0 -7
- data/lib/git_reflow/os_detector.rb +0 -23
- data/lib/git_reflow/workflows/flat_merge.rb +0 -10
- data/spec/fixtures/workflow_with_super.rb +0 -8
data/Rakefile
CHANGED
@@ -1,8 +1,15 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require "bundler/gem_tasks"
|
3
|
-
require "rspec/core/rake_task"
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
require "github_changelog_generator/task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
9
|
+
config.user = 'reenhanced'
|
10
|
+
config.project = 'gitreflow'
|
11
|
+
config.since_tag = 'v0.9.2'
|
12
|
+
config.future_release = 'master'
|
13
|
+
end
|
14
|
+
|
15
|
+
task :default => :spec
|
data/Workflow
ADDED
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-modernist
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "git_reflow"
|
5
|
-
|
6
|
-
require "irb"
|
7
|
-
IRB.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "git_reflow"
|
5
|
+
|
6
|
+
require "irb"
|
7
|
+
IRB.start
|
data/bin/setup
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
data/exe/git-reflow
CHANGED
@@ -1,36 +1,20 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
3
|
-
require 'rubygems'
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
true
|
22
|
-
end
|
23
|
-
|
24
|
-
post do |global,command,options,args|
|
25
|
-
# Post logic here
|
26
|
-
# Use skips_post before a command to skip this
|
27
|
-
# block on that command only
|
28
|
-
end
|
29
|
-
|
30
|
-
on_error do |exception|
|
31
|
-
# Error logic here
|
32
|
-
# return false to skip default error handling
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
exit run(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
3
|
+
require 'rubygems'
|
4
|
+
require 'git_reflow'
|
5
|
+
|
6
|
+
reflow_command = ARGV.shift
|
7
|
+
if reflow_command.nil? || GitReflow.workflow.commands[reflow_command.to_sym].nil?
|
8
|
+
GitReflow.help
|
9
|
+
elsif ARGV.include? "--help"
|
10
|
+
GitReflow.documentation_for_command(reflow_command)
|
11
|
+
else
|
12
|
+
trap 'INT' do
|
13
|
+
GitReflow.say "Aborted.", :error
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
command_options = GitReflow.parse_command_options!(reflow_command)
|
18
|
+
GitReflow.logger.debug "Running command `#{reflow_command}` with options: #{command_options.inspect}"
|
19
|
+
GitReflow.public_send(reflow_command.to_sym, command_options)
|
20
|
+
end
|
data/git_reflow.gemspec
CHANGED
@@ -1,44 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Ensure we require the local version and not one we might have installed already
|
2
|
-
require File.join([File.dirname(__FILE__),'lib','git_reflow/version.rb'])
|
4
|
+
require File.join([File.dirname(__FILE__), 'lib', 'git_reflow/version.rb'])
|
3
5
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
-
s.license
|
7
|
-
s.authors
|
8
|
-
s.email
|
9
|
-
s.homepage
|
10
|
-
s.summary
|
11
|
-
s.description
|
12
|
-
s.platform
|
13
|
-
s.files
|
14
|
-
s.test_files
|
15
|
-
s.executables
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.require_paths = ["lib"]
|
20
|
-
s.rdoc_options << '--title' << 'git_reflow' << '--main' << 'README.rdoc' << '-ri'
|
6
|
+
s.name = 'git_reflow'
|
7
|
+
s.version = GitReflow::VERSION
|
8
|
+
s.license = 'MIT'
|
9
|
+
s.authors = ['Valentino Stoll', 'Robert Stern', 'Nicholas Hance']
|
10
|
+
s.email = ['dev@reenhanced.com']
|
11
|
+
s.homepage = 'http://github.com/reenhanced/gitreflow'
|
12
|
+
s.summary = 'A better git process'
|
13
|
+
s.description = 'Git Reflow manages your git workflow.'
|
14
|
+
s.platform = Gem::Platform::RUBY
|
15
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
s.bindir = 'exe'
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.rdoc_options << '--title' << 'git_reflow' << '-ri'
|
21
21
|
|
22
|
-
s.add_development_dependency('appraisal', '2.
|
23
|
-
s.add_development_dependency('bundler', "~> 1.12")
|
22
|
+
s.add_development_dependency('appraisal', '2.2.0')
|
24
23
|
s.add_development_dependency('chronic')
|
24
|
+
s.add_development_dependency('github_changelog_generator')
|
25
25
|
s.add_development_dependency('pry-byebug')
|
26
|
-
s.add_development_dependency('rake',
|
26
|
+
s.add_development_dependency('rake', '~> 13.0.1')
|
27
27
|
s.add_development_dependency('rdoc')
|
28
|
-
s.add_development_dependency('rspec',
|
28
|
+
s.add_development_dependency('rspec', '~> 3.9')
|
29
29
|
s.add_development_dependency('webmock')
|
30
|
-
s.add_development_dependency('wwtd', '1.
|
30
|
+
s.add_development_dependency('wwtd', '1.4')
|
31
31
|
|
32
|
+
s.add_dependency('bundler', '>= 1.10.0')
|
33
|
+
s.add_dependency('codenamev_bitbucket_api', '0.4.1')
|
32
34
|
s.add_dependency('colorize', '>= 0.7.0')
|
33
|
-
s.add_dependency('
|
35
|
+
s.add_dependency('github_api', '0.18.2')
|
34
36
|
s.add_dependency('highline')
|
35
37
|
s.add_dependency('httpclient')
|
36
|
-
s.add_dependency('github_api', '0.15.0')
|
37
|
-
# rack is a dependency of oauth2, which is a dependency of github_api
|
38
|
-
# The latest rack only supports ruby > 2.2.2, so we lock this down until
|
39
|
-
# support for ruby 2.1.x is dropped
|
40
|
-
s.add_dependency('rack', ['>= 1.2', '< 2'])
|
41
|
-
s.add_dependency('reenhanced_bitbucket_api', '0.3.2')
|
42
38
|
|
43
39
|
s.post_install_message = "You need to setup your GitHub OAuth token\nPlease run 'git-reflow setup'"
|
44
40
|
end
|
data/lib/git_reflow.rb
CHANGED
@@ -6,13 +6,6 @@ require 'httpclient'
|
|
6
6
|
require 'json'
|
7
7
|
require 'colorize'
|
8
8
|
|
9
|
-
# XXX: work around logger spam from hashie (required by github api)
|
10
|
-
# https://github.com/intridea/hashie/issues/394
|
11
|
-
require "hashie"
|
12
|
-
require "hashie/logger"
|
13
|
-
Hashie.logger = Logger.new(nil)
|
14
|
-
|
15
|
-
|
16
9
|
require 'github_api'
|
17
10
|
require 'git_reflow/version.rb' unless defined?(GitReflow::VERSION)
|
18
11
|
require 'git_reflow/config'
|
@@ -22,7 +15,6 @@ require 'git_reflow/git_server/bit_bucket'
|
|
22
15
|
require 'git_reflow/git_server/git_hub'
|
23
16
|
require 'git_reflow/logger'
|
24
17
|
require 'git_reflow/merge_error'
|
25
|
-
require 'git_reflow/os_detector'
|
26
18
|
require 'git_reflow/sandbox'
|
27
19
|
require 'git_reflow/workflow'
|
28
20
|
require 'git_reflow/workflows/core'
|
@@ -47,20 +39,16 @@ module GitReflow
|
|
47
39
|
Workflow.current
|
48
40
|
end
|
49
41
|
|
50
|
-
def default_editor
|
51
|
-
"#{ENV['EDITOR'] || 'vi'}".freeze
|
52
|
-
end
|
53
|
-
|
54
42
|
def git_server
|
55
43
|
@git_server ||= GitServer.connect provider: GitReflow::Config.get('reflow.git-server').strip, silent: true
|
56
44
|
end
|
57
45
|
|
58
|
-
def
|
59
|
-
(workflow
|
46
|
+
def respond_to_missing?(method_sym, include_all = false)
|
47
|
+
(workflow && workflow.respond_to?(method_sym, include_all)) || super(method_sym, include_all)
|
60
48
|
end
|
61
49
|
|
62
50
|
def method_missing(method_sym, *arguments, &block)
|
63
|
-
if workflow
|
51
|
+
if workflow && workflow.respond_to?(method_sym, false)
|
64
52
|
workflow.send method_sym, *arguments, &block
|
65
53
|
else
|
66
54
|
super
|
data/lib/git_reflow/config.rb
CHANGED
@@ -1,25 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module GitReflow
|
4
|
+
# This is a utility module for getting and setting git-config variables.
|
2
5
|
module Config
|
3
|
-
|
6
|
+
CONFIG_FILE_PATH = "#{ENV['HOME']}/.gitconfig.reflow"
|
4
7
|
|
5
|
-
|
8
|
+
module_function
|
6
9
|
|
10
|
+
# Gets the reqested git configuration variable.
|
11
|
+
#
|
12
|
+
# @param [String] key The key to get the value(s) for
|
13
|
+
# @option options [Boolean] :reload (false) whether to reload the value or use a cached value if available
|
14
|
+
# @option options [Boolean] :all (false) whether to return all keys for a multi-valued key
|
15
|
+
# @option options [Boolean] :local (false) whether to get the value specific to the current project
|
16
|
+
# @return the value of the git configuration
|
7
17
|
def get(key, reload: false, all: false, local: false)
|
8
|
-
|
9
|
-
|
18
|
+
return cached_git_config_value(key) unless reload || cached_git_config_value(key).empty?
|
19
|
+
|
20
|
+
local = local ? '--local ' : ''
|
21
|
+
if all
|
22
|
+
new_value = GitReflow::Sandbox.run("git config #{local}--get-all #{key}", loud: false, blocking: false)
|
10
23
|
else
|
11
|
-
|
12
|
-
if all
|
13
|
-
new_value = GitReflow::Sandbox.run("git config #{local}--get-all #{key}", loud: false, blocking: false)
|
14
|
-
else
|
15
|
-
new_value = GitReflow::Sandbox.run("git config #{local}--get #{key}", loud: false, blocking: false)
|
16
|
-
end
|
17
|
-
instance_variable_set(:"@#{key.tr('.-', '_')}", new_value.strip)
|
24
|
+
new_value = GitReflow::Sandbox.run("git config #{local}--get #{key}", loud: false, blocking: false)
|
18
25
|
end
|
26
|
+
cache_git_config_key(key, new_value)
|
19
27
|
end
|
20
28
|
|
29
|
+
# Sets the reqested git configuration variable.
|
30
|
+
#
|
31
|
+
# @param [String] key The key to set the value for
|
32
|
+
# @param [String] value The value to set it to
|
33
|
+
# @option options [Boolean] :local (false) whether to set the value specific to the current project
|
34
|
+
# @return the value of the git configuration
|
21
35
|
def set(key, value, local: false)
|
22
|
-
value =
|
36
|
+
value = value.to_s.strip
|
23
37
|
if local
|
24
38
|
GitReflow::Sandbox.run "git config --replace-all #{key} \"#{value}\"", loud: false, blocking: false
|
25
39
|
else
|
@@ -27,8 +41,14 @@ module GitReflow
|
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
44
|
+
# Remove values of the reqested git configuration variable.
|
45
|
+
#
|
46
|
+
# @param [String] key The key to remove
|
47
|
+
# @option options [Boolean] :value (nil) The value of the key to remove
|
48
|
+
# @option options [Boolean] :local (false) whether to remove the value specific to the current project
|
49
|
+
# @return the result of running the git command
|
30
50
|
def unset(key, value: nil, local: false)
|
31
|
-
value =
|
51
|
+
value = value.nil? ? '' : "\"#{value}\""
|
32
52
|
if local
|
33
53
|
GitReflow::Sandbox.run "git config --unset-all #{key} #{value}", loud: false, blocking: false
|
34
54
|
else
|
@@ -36,6 +56,13 @@ module GitReflow
|
|
36
56
|
end
|
37
57
|
end
|
38
58
|
|
59
|
+
# Adds a new git configuration variable.
|
60
|
+
#
|
61
|
+
# @param [String] key The new key to set the value for
|
62
|
+
# @param [String] value The value to set it to
|
63
|
+
# @option options [Boolean] :local (false) whether to set the value specific to the current project
|
64
|
+
# @option options [Boolean] :global (false) whether to set the value globaly. if neither local or global is set gitreflow will default to using a configuration file
|
65
|
+
# @return the result of running the git command
|
39
66
|
def add(key, value, local: false, global: false)
|
40
67
|
if global
|
41
68
|
GitReflow::Sandbox.run "git config --global --add #{key} \"#{value}\"", loud: false, blocking: false
|
@@ -45,5 +72,13 @@ module GitReflow
|
|
45
72
|
GitReflow::Sandbox.run "git config -f #{CONFIG_FILE_PATH} --add #{key} \"#{value}\"", loud: false, blocking: false
|
46
73
|
end
|
47
74
|
end
|
75
|
+
|
76
|
+
def cached_git_config_value(key)
|
77
|
+
instance_variable_get(:"@#{key.tr('.-', '_')}").to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
def cache_git_config_key(key, value)
|
81
|
+
instance_variable_set(:"@#{key.tr('.-', '_')}", value.to_s.strip)
|
82
|
+
end
|
48
83
|
end
|
49
84
|
end
|
@@ -1,51 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'git_reflow/config'
|
2
4
|
require 'git_reflow/sandbox'
|
3
5
|
|
4
6
|
module GitReflow
|
7
|
+
# Includes many helper methods for common tasks within a git repository.
|
5
8
|
module GitHelpers
|
6
9
|
include Sandbox
|
7
10
|
|
11
|
+
def default_editor
|
12
|
+
ENV['EDITOR'] || 'vi'
|
13
|
+
end
|
14
|
+
|
8
15
|
def git_root_dir
|
9
|
-
return @git_root_dir
|
16
|
+
return @git_root_dir unless @git_root_dir.to_s.empty?
|
10
17
|
@git_root_dir = run('git rev-parse --show-toplevel', loud: false).strip
|
11
18
|
end
|
12
19
|
|
13
20
|
def git_editor_command
|
14
|
-
git_editor =
|
15
|
-
if git_editor.
|
21
|
+
git_editor = GitReflow::Config.get('core.editor')
|
22
|
+
if !git_editor.empty?
|
16
23
|
git_editor
|
17
24
|
else
|
18
|
-
|
25
|
+
default_editor
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
29
|
def remote_user
|
23
|
-
return
|
30
|
+
return '' if GitReflow::Config.get('remote.origin.url').empty?
|
24
31
|
extract_remote_user_and_repo_from_remote_url(GitReflow::Config.get('remote.origin.url'))[:user]
|
25
32
|
end
|
26
33
|
|
27
34
|
def remote_repo_name
|
28
|
-
return
|
35
|
+
return '' if GitReflow::Config.get('remote.origin.url').empty?
|
29
36
|
extract_remote_user_and_repo_from_remote_url(GitReflow::Config.get('remote.origin.url'))[:repo]
|
30
37
|
end
|
31
38
|
|
39
|
+
def default_base_branch
|
40
|
+
base_branch_name = GitReflow::Config.get('reflow.base-branch')
|
41
|
+
return 'master' if base_branch_name.empty?
|
42
|
+
base_branch_name
|
43
|
+
end
|
44
|
+
|
32
45
|
def current_branch
|
33
46
|
run("git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'", loud: false).strip
|
34
47
|
end
|
35
48
|
|
36
49
|
def pull_request_template
|
37
|
-
filenames_to_try = %w
|
38
|
-
|
39
|
-
|
40
|
-
|
50
|
+
filenames_to_try = %w[.github/PULL_REQUEST_TEMPLATE.md
|
51
|
+
.github/PULL_REQUEST_TEMPLATE
|
52
|
+
PULL_REQUEST_TEMPLATE.md
|
53
|
+
PULL_REQUEST_TEMPLATE].map do |file|
|
41
54
|
"#{git_root_dir}/#{file}"
|
42
55
|
end
|
43
56
|
|
44
|
-
|
45
|
-
|
57
|
+
parse_first_matching_template_file(filenames_to_try)
|
58
|
+
end
|
59
|
+
|
60
|
+
def merge_commit_template
|
61
|
+
filenames_to_try = %w[.github/MERGE_COMMIT_TEMPLATE.md
|
62
|
+
.github/MERGE_COMMIT_TEMPLATE
|
63
|
+
MERGE_COMMIT_TEMPLATE.md
|
64
|
+
MERGE_COMMIT_TEMPLATE].map do |file|
|
65
|
+
"#{git_root_dir}/#{file}"
|
46
66
|
end
|
47
67
|
|
48
|
-
|
68
|
+
parse_first_matching_template_file(filenames_to_try)
|
49
69
|
end
|
50
70
|
|
51
71
|
def get_first_commit_message
|
@@ -53,12 +73,12 @@ module GitReflow
|
|
53
73
|
end
|
54
74
|
|
55
75
|
def push_current_branch(options = {})
|
56
|
-
remote = options[:remote] ||
|
76
|
+
remote = options[:remote] || 'origin'
|
57
77
|
run_command_with_label "git push #{remote} #{current_branch}"
|
58
78
|
end
|
59
79
|
|
60
80
|
def update_current_branch(options = {})
|
61
|
-
remote = options[:remote] ||
|
81
|
+
remote = options[:remote] || 'origin'
|
62
82
|
run_command_with_label "git pull #{remote} #{current_branch}"
|
63
83
|
push_current_branch(options)
|
64
84
|
end
|
@@ -86,23 +106,50 @@ module GitReflow
|
|
86
106
|
run_command_with_label "git merge #{base_branch}"
|
87
107
|
end
|
88
108
|
|
89
|
-
def
|
90
|
-
|
91
|
-
|
92
|
-
|
109
|
+
def append_to_merge_commit_message(message = '', merge_method: "squash")
|
110
|
+
tmp_merge_message_path = "#{git_root_dir}/.git/tmp_merge_msg"
|
111
|
+
dest_merge_message_path = merge_message_path(merge_method: merge_method)
|
112
|
+
|
113
|
+
run "touch #{tmp_merge_message_path}"
|
114
|
+
|
115
|
+
File.open(tmp_merge_message_path, "w") do |file_content|
|
93
116
|
file_content.puts message
|
94
|
-
if File.exists?
|
95
|
-
File.foreach(
|
117
|
+
if File.exists? dest_merge_message_path
|
118
|
+
File.foreach(dest_merge_message_path) do |line|
|
96
119
|
file_content.puts line
|
97
120
|
end
|
98
121
|
end
|
99
122
|
end
|
100
123
|
|
101
|
-
run "mv #{
|
124
|
+
run "mv #{tmp_merge_message_path} #{dest_merge_message_path}"
|
125
|
+
end
|
126
|
+
|
127
|
+
def merge_message_path(merge_method: nil)
|
128
|
+
merge_method = merge_method || GitReflow::Config.get("reflow.merge-method")
|
129
|
+
merge_method = "squash" if "#{merge_method}".length < 1
|
130
|
+
if merge_method =~ /squash/i
|
131
|
+
"#{git_root_dir}/.git/SQUASH_MSG"
|
132
|
+
else
|
133
|
+
"#{git_root_dir}/.git/MERGE_MSG"
|
134
|
+
end
|
102
135
|
end
|
103
136
|
|
104
137
|
private
|
105
138
|
|
139
|
+
def parse_first_matching_template_file(template_file_names)
|
140
|
+
filename = template_file_names.detect do |file|
|
141
|
+
File.exist? file
|
142
|
+
end
|
143
|
+
|
144
|
+
# Thanks to @Shalmezad for contribuiting the template `gsub` snippet :-)
|
145
|
+
# https://github.com/reenhanced/gitreflow/issues/51#issuecomment-253535093
|
146
|
+
if filename
|
147
|
+
template_content = File.read filename
|
148
|
+
template_content.gsub!(/\{\{([a-zA-Z_]+[a-zA-Z0-9_]*)\}\}/) { GitReflow.public_send($1) }
|
149
|
+
template_content
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
106
153
|
def extract_remote_user_and_repo_from_remote_url(remote_url)
|
107
154
|
result = { user: '', repo: '' }
|
108
155
|
return result unless "#{remote_url}".length > 0
|