github_flow_cli 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/exe/hubflow +1 -3
- data/lib/commands/issue.rb +8 -1
- data/lib/commands/pr.rb +13 -1
- data/lib/github_flow_cli/cli.rb +0 -1
- data/lib/github_flow_cli/config.rb +2 -2
- data/lib/github_flow_cli/local.rb +10 -1
- data/lib/github_flow_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a44a07d009f36c0f65a79e8b9e509864f3f08f7
|
4
|
+
data.tar.gz: 34229676929d20b34624c342a1beba61f76f72fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2c5b01196984c29d06984db654471418ec2d834a58bfa687f492a3990a77da28284ca4435941458e0902d8e84e8a335b26eb0de8fae279e5039a1781ef3a53
|
7
|
+
data.tar.gz: f107a08bf3fafe3690f442e2a9636d97a106c977bf17009b353d82f2af1f764fe16904c685961bbe8216da9e98ef460eeeab471f3822d8638c2f3973f9832d62
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,6 +24,8 @@ For the very first version, I present a workflow that is 100% browser-free until
|
|
24
24
|
|
25
25
|
![image](https://user-images.githubusercontent.com/3524125/40894925-82156c58-6761-11e8-9f21-2d467426bd58.png)
|
26
26
|
|
27
|
+
First make sure your working directory is under a git repository.
|
28
|
+
|
27
29
|
1. When you're in ready position, check your ticket list via `hubflow issue mine`;
|
28
30
|
2. Pick a ticket to work on via `hubflow issue start NUMBER`, this will create a branch based on the issue number and name;
|
29
31
|
3. After you finished your work, just hit `hubflow pr create`, it will:
|
data/exe/hubflow
CHANGED
data/lib/commands/issue.rb
CHANGED
@@ -28,6 +28,11 @@ module GithubFlowCli
|
|
28
28
|
|
29
29
|
desc "start", "create a new branch named after the issue"
|
30
30
|
def start(number)
|
31
|
+
# TODO: before filer
|
32
|
+
unless Local.repo
|
33
|
+
puts "not valid outside of a git repo."
|
34
|
+
exit(4)
|
35
|
+
end
|
31
36
|
issue = API.issue(Local.repo, number)
|
32
37
|
# TODO: create branch based on RepoRules
|
33
38
|
# TODO: abstarct tag from issue title
|
@@ -44,7 +49,9 @@ module GithubFlowCli
|
|
44
49
|
show_assignee = config.delete(:show_assignee)
|
45
50
|
issues = API.list_issues(Local.repo, config)
|
46
51
|
unless issues.empty?
|
47
|
-
|
52
|
+
msgs = issues.sort_by(&:title).map { |i| "#{Local.repo ? '' : i.repository.name}##{i.number}#{assignee_field(show_assignee, i)}: #{i.title}" }
|
53
|
+
msgs.sort_by!(&:itself) unless Local.repo
|
54
|
+
puts msgs
|
48
55
|
end
|
49
56
|
end
|
50
57
|
|
data/lib/commands/pr.rb
CHANGED
@@ -6,14 +6,24 @@ module GithubFlowCli
|
|
6
6
|
class PrCommands < Thor
|
7
7
|
desc "all", "list all open PR"
|
8
8
|
def all
|
9
|
+
# TODO: before filer
|
10
|
+
unless Local.repo
|
11
|
+
puts "not valid outside of a git repo."
|
12
|
+
exit(4)
|
13
|
+
end
|
9
14
|
pull_requests = API.pull_requests(Local.repo)
|
10
15
|
unless pull_requests.empty?
|
11
|
-
puts pull_requests.map { |p| "##{p.number} (#{p.assignee&.login || "NONE"}): #{p.title}" }
|
16
|
+
puts pull_requests.map { |p| "#{Local.repo ? '' : i.repository.name}##{p.number} (#{p.assignee&.login || "NONE"}): #{p.title}" }
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
15
20
|
desc "create TITLE", "create PR from current branch"
|
16
21
|
def create(title = nil)
|
22
|
+
# TODO: before filer
|
23
|
+
unless Local.repo
|
24
|
+
puts "not valid outside of a git repo."
|
25
|
+
exit(4)
|
26
|
+
end
|
17
27
|
puts API.create_pr(title: title).html_url
|
18
28
|
rescue Octokit::UnprocessableEntity => ex
|
19
29
|
case ex.message
|
@@ -23,6 +33,8 @@ module GithubFlowCli
|
|
23
33
|
puts "PR already exists."
|
24
34
|
pr_number = Config.pr_branch_map.find {|_, v| v == Local.git.current_branch }.first
|
25
35
|
puts API.pull_request(Local.repo, pr_number).html_url
|
36
|
+
when /missing_field/
|
37
|
+
puts "issue info lost, please provide the title"
|
26
38
|
else
|
27
39
|
raise
|
28
40
|
end
|
data/lib/github_flow_cli/cli.rb
CHANGED
@@ -12,7 +12,6 @@ module GithubFlowCli
|
|
12
12
|
Config.username = ask("Github username:")
|
13
13
|
password = ask("password:", echo: false)
|
14
14
|
Config.oauth_token = authorize(Config.username, password)
|
15
|
-
Config.save!
|
16
15
|
puts "\nsuccessfully login!"
|
17
16
|
rescue Octokit::Unauthorized
|
18
17
|
puts "\nauthentication failed, please try again."
|
@@ -13,8 +13,6 @@ module GithubFlowCli
|
|
13
13
|
attr_accessor *KEYS
|
14
14
|
|
15
15
|
def setup
|
16
|
-
self.branch_issue_map = {}
|
17
|
-
self.pr_branch_map = {}
|
18
16
|
if File.file?(config_path)
|
19
17
|
load
|
20
18
|
API.use_oauth_token(oauth_token)
|
@@ -42,6 +40,8 @@ module GithubFlowCli
|
|
42
40
|
end
|
43
41
|
|
44
42
|
def save!
|
43
|
+
self.branch_issue_map ||= {}
|
44
|
+
self.pr_branch_map ||= {}
|
45
45
|
File.open(config_path, 'w') { |f| f.write(to_h.to_yaml) }
|
46
46
|
end
|
47
47
|
|
@@ -18,7 +18,16 @@ module GithubFlowCli
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def git
|
21
|
-
@git ||= Git.open(
|
21
|
+
@git ||= Git.open(git_dir)
|
22
|
+
end
|
23
|
+
|
24
|
+
def git_dir
|
25
|
+
current = File.expand_path('.')
|
26
|
+
while !File.directory?(File.join(current, '.git'))
|
27
|
+
current = File.dirname(current)
|
28
|
+
break if current == '/'
|
29
|
+
end
|
30
|
+
current
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|