straight_line 0.1.1.0 → 0.1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile +1 -1
- data/README.md +7 -0
- data/VERSION +1 -1
- data/lib/straight_line/common/command.rb +14 -5
- data/lib/straight_line/common/configure.rb +29 -0
- data/lib/straight_line/common/feature/create.rb +1 -1
- data/lib/straight_line/common/feature/diff.rb +5 -7
- data/lib/straight_line/common/feature/land.rb +21 -16
- data/lib/straight_line/common/feature.rb +6 -6
- data/lib/straight_line/common/git_commands/merge.rb +1 -1
- data/lib/straight_line/common/git_commands/push.rb +3 -3
- data/lib/straight_line/common/git_commands/rebase.rb +1 -1
- data/lib/straight_line/common/git_commands.rb +6 -3
- data/lib/straight_line/common/github.rb +2 -2
- data/lib/straight_line/common/shell_error.rb +1 -2
- data/lib/straight_line/common/util.rb +2 -1
- data/lib/straight_line.rb +9 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dee8f1abb4db6de0c401f3f4008943ddb3f58e5b
|
4
|
+
data.tar.gz: 6a1914f27db3929a0bd3a7c7eff9fb7e65633e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a0e5616ab2d8bf7c57a1cd8072565e4157d581d9a5891f4aa1814d4425037979a81b5ea1edbb584833415fb2073afb693b277ef54178f90db9754a9e0b39b2
|
7
|
+
data.tar.gz: 1626f216dcdcbedfd054e40e5139af55a622dd65c2d064d07e49aa4f33296fb7bac07e3b2b4a07ad10ceee858f663658ed4d205e6a2223b63aa2d5a712e8e780
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -31,6 +31,13 @@ machine api.github.com
|
|
31
31
|
login <Your Github username>
|
32
32
|
password <Github API token>
|
33
33
|
```
|
34
|
+
|
35
|
+
Note `~/.netrc` needs to have `600` permissions. Do this with the following command:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
chmod 600 ~/.netrc
|
39
|
+
```
|
40
|
+
|
34
41
|
## Usage
|
35
42
|
|
36
43
|
The basic workflow of StraightLine is:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2.0
|
@@ -16,6 +16,8 @@ class Command
|
|
16
16
|
self
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.from_file(_file_name); end
|
20
|
+
|
19
21
|
def run(return_stderr = false)
|
20
22
|
Dir.chdir working_dir do
|
21
23
|
command_with_params = "#{@command} #{@args.join ' '}"
|
@@ -25,21 +27,28 @@ class Command
|
|
25
27
|
else
|
26
28
|
res, stderr, status = Open3.capture3(command_with_params)
|
27
29
|
end
|
28
|
-
unless status.exitstatus
|
30
|
+
unless status.exitstatus.zero?
|
29
31
|
output = return_stderr ? res : "#{res}\n#{stderr}"
|
30
32
|
raise ShellError, %(Command `#{command_with_params}` exited with
|
31
33
|
status code: #{status.exitstatus}. Command outputted:\n #{output})
|
32
34
|
end
|
33
35
|
|
34
|
-
sub_res =
|
35
|
-
sub_res = @sub_commands.map do |sub_command|
|
36
|
-
sub_command.run return_stderr
|
37
|
-
end.join("\n") unless @sub_commands.empty?
|
36
|
+
sub_res = run_sub_commands return_stderr
|
38
37
|
|
39
38
|
res + "\n" + sub_res
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
42
|
+
def run_sub_commands(return_stderr)
|
43
|
+
sub_res = ''
|
44
|
+
unless @sub_commands.empty?
|
45
|
+
sub_res = @sub_commands.map do |sub_command|
|
46
|
+
sub_command.run return_stderr
|
47
|
+
end.join("\n")
|
48
|
+
end
|
49
|
+
sub_res
|
50
|
+
end
|
51
|
+
|
43
52
|
def sub_command(command)
|
44
53
|
unless command.is_a? Command
|
45
54
|
raise ArgumentError, 'command must be of type straight_line/common/command'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'straight_line/common/command'
|
3
|
+
|
4
|
+
# Configuration class to add tasks to the straightline rake config
|
5
|
+
class Configure
|
6
|
+
def add(name, type, command, opts = {})
|
7
|
+
Rake.application.in_namespace StraightLine::TASK_NAMESPACE do
|
8
|
+
Rake::Task.define_task name => opts[:before] do
|
9
|
+
if type == :shell
|
10
|
+
cmd = Command.new command
|
11
|
+
cmd.run
|
12
|
+
elsif !name.nil?
|
13
|
+
Rake::Task[command].invoke
|
14
|
+
end
|
15
|
+
run_after_commands(opts)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def run_after_commands(opts)
|
23
|
+
after = opts[:after]
|
24
|
+
return if after.nil?
|
25
|
+
after.each do |task|
|
26
|
+
Rake::Task[task].invoke
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -6,7 +6,7 @@ module Feature
|
|
6
6
|
class Create
|
7
7
|
def initialize(feature_name)
|
8
8
|
raise UserError, 'Feature name required' unless feature_name
|
9
|
-
raise UserError, "Feature name can't have spaces" if feature_name
|
9
|
+
raise UserError, "Feature name can't have spaces" if feature_name =~ /\s/
|
10
10
|
@feature_name = feature_name
|
11
11
|
end
|
12
12
|
|
@@ -42,9 +42,7 @@ module Feature
|
|
42
42
|
begin
|
43
43
|
GitCommands::Commit.new(title, body).run
|
44
44
|
rescue StandardError => e
|
45
|
-
unless e.message
|
46
|
-
raise e
|
47
|
-
end
|
45
|
+
raise e unless e.message =~ /nothing to commit/
|
48
46
|
end
|
49
47
|
GitCommands::Push.new(feature_name).run
|
50
48
|
end
|
@@ -68,10 +66,10 @@ module Feature
|
|
68
66
|
def extract_params(params, keys)
|
69
67
|
keys.map do |key|
|
70
68
|
case key
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
when :title
|
70
|
+
params[:title] || last_commit_message
|
71
|
+
else
|
72
|
+
params[key]
|
75
73
|
end
|
76
74
|
end
|
77
75
|
end
|
@@ -22,28 +22,33 @@ module Feature
|
|
22
22
|
|
23
23
|
def land(_args = {})
|
24
24
|
feature_name = current_feature
|
25
|
-
|
26
|
-
pull_cmd.run
|
27
|
-
GitCommands::Merge.new(feature_name, 'master').run
|
28
|
-
|
29
|
-
begin
|
30
|
-
GitCommands::Commit.new("Merge master into #{feature_name}", '').run
|
31
|
-
rescue StandardError => e
|
32
|
-
unless e.message.match %r[nothing to commit]
|
33
|
-
raise e
|
34
|
-
end
|
35
|
-
end
|
25
|
+
merge_master_to_feature(feature_name)
|
36
26
|
GitCommands::Push.new(feature_name).run
|
27
|
+
merge_feature_to_master(feature_name)
|
28
|
+
GitCommands::Push.new(feature_name, delete: true).run
|
29
|
+
Command.new('git checkout master').run
|
30
|
+
Util.logger.info 'Changes landed to master, on master branch now.'
|
31
|
+
end
|
32
|
+
|
33
|
+
def merge_feature_to_master(feature_name)
|
37
34
|
if pull_request_closed?(feature_name)
|
38
|
-
Util.logger.info %
|
39
|
-
You're repo is up-to-date with remote
|
35
|
+
Util.logger.info %(#{feature_name} was merged in github.
|
36
|
+
You're repo is up-to-date with remote)
|
40
37
|
else
|
41
38
|
GitCommands::Merge.new('master', feature_name).run
|
42
39
|
GitCommands::Push.new('master').run
|
43
40
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
end
|
42
|
+
|
43
|
+
def merge_master_to_feature(feature_name)
|
44
|
+
GitCommands::Pull.new('master').run
|
45
|
+
GitCommands::Merge.new(feature_name, 'master').run
|
46
|
+
|
47
|
+
begin
|
48
|
+
GitCommands::Commit.new("Merge master into #{feature_name}", '').run
|
49
|
+
rescue StandardError => e
|
50
|
+
raise e unless e.message =~ /nothing to commit/
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
54
|
def pull_request_closed?(feature_name)
|
@@ -3,12 +3,12 @@ require 'straight_line/common/command'
|
|
3
3
|
module Feature
|
4
4
|
def current_feature
|
5
5
|
res = Command.new('git')
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
if res
|
10
|
-
raise UserError,
|
11
|
-
Finish the rebase, then run the command again
|
6
|
+
.arg('branch')
|
7
|
+
.run
|
8
|
+
.match(/^\*\s+(.*)/)[1].strip
|
9
|
+
if res =~ /no branch/
|
10
|
+
raise UserError, 'A rebase is in process.
|
11
|
+
Finish the rebase, then run the command again'
|
12
12
|
else
|
13
13
|
res
|
14
14
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'straight_line/common/util'
|
2
|
+
|
3
|
+
# Util class for common git related actions
|
2
4
|
module GitCommands
|
3
5
|
def handle_merge_conflict(e)
|
4
|
-
if e.message
|
5
|
-
Util.logger.error
|
6
|
-
Try fixing the conflicts, then run `git add .` and then run the
|
6
|
+
if e.message =~ /Merge conflict in/
|
7
|
+
Util.logger.error '***** Hint: this looks like a merge conflict.
|
8
|
+
Try fixing the conflicts, then run `git add .` and then run the
|
9
|
+
previous command again.'
|
7
10
|
end
|
8
11
|
raise e
|
9
12
|
end
|
@@ -68,8 +68,8 @@ class Github
|
|
68
68
|
prs = pull_requests
|
69
69
|
prs.find do |p|
|
70
70
|
p.head.ref == feature &&
|
71
|
-
|
72
|
-
|
71
|
+
p.head.user.login == Github.github_login &&
|
72
|
+
p.base.ref == 'master'
|
73
73
|
end
|
74
74
|
end
|
75
75
|
make_class :pull_request_for_feature
|
data/lib/straight_line.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
require 'straight_line/common/configure'
|
2
|
+
require 'rake'
|
1
3
|
|
2
4
|
# Base module definition
|
3
5
|
module StraightLine
|
4
|
-
|
5
|
-
def self.
|
6
|
-
|
6
|
+
TASK_NAMESPACE = 'sl'.freeze
|
7
|
+
def self.configure
|
8
|
+
yield Configure.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.task_namespace
|
12
|
+
Rake::DSL
|
7
13
|
end
|
8
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: straight_line
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Usick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/straight_line/cli/application.rb
|
123
123
|
- lib/straight_line/cli/feature.rb
|
124
124
|
- lib/straight_line/common/command.rb
|
125
|
+
- lib/straight_line/common/configure.rb
|
125
126
|
- lib/straight_line/common/feature.rb
|
126
127
|
- lib/straight_line/common/feature/create.rb
|
127
128
|
- lib/straight_line/common/feature/diff.rb
|