abak-flow 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +10 -1
- data/README.md +13 -30
- data/Rakefile +25 -0
- data/VERSION +1 -1
- data/abak-flow.gemspec +23 -19
- data/bin/request +1 -2
- data/lib/abak-flow/branch.rb +108 -0
- data/lib/abak-flow/branches.rb +68 -0
- data/lib/abak-flow/configuration.rb +67 -0
- data/lib/abak-flow/locales/en.yml +32 -0
- data/lib/abak-flow/locales/ru.yml +32 -0
- data/lib/abak-flow/manager.rb +35 -0
- data/lib/abak-flow/messages.rb +86 -0
- data/lib/abak-flow/pull_request.rb +39 -199
- data/lib/abak-flow/repository.rb +71 -0
- data/lib/abak-flow/request.rb +88 -198
- data/lib/abak-flow/version.rb +1 -1
- data/lib/abak-flow/visitor.rb +43 -0
- data/lib/abak-flow.rb +20 -13
- data/spec/abak-flow/branch_spec.rb +55 -0
- data/spec/abak-flow/branches_spec.rb +20 -0
- data/spec/abak-flow/configuration_spec.rb +73 -0
- data/spec/abak-flow/git_spec.rb +12 -0
- data/spec/abak-flow/github_client_spec.rb +15 -0
- data/spec/abak-flow/messages_spec.rb +146 -0
- data/spec/abak-flow/project_spec.rb +52 -0
- data/spec/abak-flow/pull_request_spec.rb +353 -0
- data/spec/abak-flow/system_spec.rb +97 -0
- data/spec/spec_helper.rb +17 -0
- metadata +82 -31
- data/lib/abak-flow/config.rb +0 -20
- data/lib/abak-flow/extensions.rb +0 -125
- data/lib/abak-flow/github_client.rb +0 -13
data/lib/abak-flow/extensions.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
module Abak::Flow
|
3
|
-
module ::Faraday
|
4
|
-
class Response::RaiseOctokitError < Response::Middleware
|
5
|
-
def error_message_with_trace(response)
|
6
|
-
message = (response[:body].errors || []).map {|error| "=> #{error.code}: #{error.message}" }.join("\n")
|
7
|
-
|
8
|
-
[error_message_without_trace(response), message].reject { |m| m.empty? }.join("\n\nДополнительные сообщения:\n")
|
9
|
-
end
|
10
|
-
alias_method :error_message_without_trace, :error_message
|
11
|
-
alias_method :error_message, :error_message_with_trace
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
class ::Hub::Runner
|
17
|
-
def execute
|
18
|
-
if args.noop?
|
19
|
-
puts commands
|
20
|
-
elsif not args.skip?
|
21
|
-
if args.chained?
|
22
|
-
execute_command_chain
|
23
|
-
else
|
24
|
-
%x{#{args.to_exec.join(' ')}}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
module ::Hub::Commands
|
31
|
-
def pull_request(args)
|
32
|
-
args.shift
|
33
|
-
options = { }
|
34
|
-
force = explicit_owner = false
|
35
|
-
base_project = local_repo.main_project
|
36
|
-
head_project = local_repo.current_project
|
37
|
-
|
38
|
-
from_github_ref = lambda do |ref, context_project|
|
39
|
-
if ref.index(':')
|
40
|
-
owner, ref = ref.split(':', 2)
|
41
|
-
project = github_project(context_project.name, owner)
|
42
|
-
end
|
43
|
-
[project || context_project, ref]
|
44
|
-
end
|
45
|
-
|
46
|
-
while arg = args.shift
|
47
|
-
case arg
|
48
|
-
when '-f'
|
49
|
-
force = true
|
50
|
-
when '-b'
|
51
|
-
base_project, options[:base] = from_github_ref.call(args.shift, base_project)
|
52
|
-
when '-h'
|
53
|
-
head = args.shift
|
54
|
-
explicit_owner = !!head.index(':')
|
55
|
-
head_project, options[:head] = from_github_ref.call(head, head_project)
|
56
|
-
when '-i'
|
57
|
-
options[:issue] = args.shift
|
58
|
-
when '-d'
|
59
|
-
options[:body] = args.shift
|
60
|
-
else
|
61
|
-
if url = resolve_github_url(arg) and url.project_path =~ /^issues\/(\d+)/
|
62
|
-
options[:issue] = $1
|
63
|
-
base_project = url.project
|
64
|
-
elsif !options[:title] then options[:title] = arg
|
65
|
-
else
|
66
|
-
abort "invalid argument: #{arg}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
options[:project] = base_project
|
72
|
-
options[:base] ||= master_branch.short_name
|
73
|
-
|
74
|
-
if tracked_branch = options[:head].nil? && current_branch.upstream
|
75
|
-
if base_project == head_project and tracked_branch.short_name == options[:base]
|
76
|
-
$stderr.puts "Aborted: head branch is the same as base (#{options[:base].inspect})"
|
77
|
-
warn "(use `-h <branch>` to specify an explicit pull request head)"
|
78
|
-
abort
|
79
|
-
end
|
80
|
-
end
|
81
|
-
options[:head] ||= (tracked_branch || current_branch).short_name
|
82
|
-
|
83
|
-
# when no tracking, assume remote branch is published under active user's fork
|
84
|
-
user = github_user(true, head_project.host)
|
85
|
-
if head_project.owner != user and !tracked_branch and !explicit_owner
|
86
|
-
head_project = head_project.owned_by(user)
|
87
|
-
end
|
88
|
-
|
89
|
-
remote_branch = "#{head_project.remote}/#{options[:head]}"
|
90
|
-
options[:head] = "#{head_project.owner}:#{options[:head]}"
|
91
|
-
|
92
|
-
if !force and tracked_branch and local_commits = git_command("rev-list --cherry #{remote_branch}...")
|
93
|
-
$stderr.puts "Aborted: #{local_commits.split("\n").size} commits are not yet pushed to #{remote_branch}"
|
94
|
-
warn "(use `-f` to force submit a pull request anyway)"
|
95
|
-
abort
|
96
|
-
end
|
97
|
-
|
98
|
-
if args.noop?
|
99
|
-
puts "Would reqest a pull to #{base_project.owner}:#{options[:base]} from #{options[:head]}"
|
100
|
-
exit
|
101
|
-
end
|
102
|
-
|
103
|
-
unless options[:title] or options[:issue]
|
104
|
-
base_branch = "#{base_project.remote}/#{options[:base]}"
|
105
|
-
changes = git_command "log --no-color --pretty=medium --cherry %s...%s" %
|
106
|
-
[base_branch, remote_branch]
|
107
|
-
|
108
|
-
options[:title], options[:body] = pullrequest_editmsg(changes) { |msg|
|
109
|
-
msg.puts "# Requesting a pull to #{base_project.owner}:#{options[:base]} from #{options[:head]}"
|
110
|
-
msg.puts "#"
|
111
|
-
msg.puts "# Write a message for this pull request. The first block"
|
112
|
-
msg.puts "# of text is the title and the rest is description."
|
113
|
-
}
|
114
|
-
end
|
115
|
-
|
116
|
-
pull = create_pullrequest(options)
|
117
|
-
|
118
|
-
args.executable = 'echo'
|
119
|
-
args.replace [pull['html_url']]
|
120
|
-
rescue HTTPExceptions
|
121
|
-
display_http_exception("creating pull request", $!.response)
|
122
|
-
exit 1
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
module Abak::Flow
|
3
|
-
class GithubClient
|
4
|
-
def self.connect(config)
|
5
|
-
return @github_connect unless @github_connect.nil?
|
6
|
-
|
7
|
-
github_options = {:login => config.api_user, :oauth_token => config.api_token}
|
8
|
-
github_options[:proxy] = config.proxy if config.proxy?
|
9
|
-
|
10
|
-
@github_connect = Octokit::Client.new(github_options)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|