devflow 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/bin/devflow +5 -19
- data/lib/devflow/command.rb +11 -0
- data/lib/devflow/commands/branch.rb +37 -0
- data/lib/devflow/commands/pr.rb +50 -0
- data/lib/devflow/version.rb +1 -1
- metadata +4 -3
- data/bin/pr_template_builder +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 522a84a07b02411019278e88f44ceb22bdce60ae90b37f1779834096aa86fc85
|
4
|
+
data.tar.gz: 04e7cdd660cd65bb4a6cbae00ed346e488f0e957337d1cbd1be5534ac75e8f16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ea1599bad93df1a17d09809693f81c4bf53506476211122d50b577e5eb37d67428fc09d2ed24035fa8aa7672995b896582d8d7dcf2acf05178179a247e82cef
|
7
|
+
data.tar.gz: 65df0c951f96bece6f5ea622714ccb624693356602ca193e7d628221072f5448ce1eac5ebbc1165af5019dcfc3c5868be7d0dd5b700bfb7141f7935276351a8e
|
data/README.md
CHANGED
@@ -23,11 +23,10 @@ This gem aims to solve that.
|
|
23
23
|
3. run `devflow` when starting working on a new story
|
24
24
|
4. Profit?
|
25
25
|
|
26
|
-
|
27
26
|
## Bonus
|
28
27
|
Install [hub](https://github.com/github/hub) and add to your .gitconfig;
|
29
28
|
```
|
30
29
|
[alias]
|
31
|
-
p-r = "!
|
30
|
+
p-r = "!devflow pr | hub -c core.commentChar=';' pull-request -oe -F -"
|
32
31
|
```
|
33
32
|
Now you can easily create PRs from the commandline!
|
data/bin/devflow
CHANGED
@@ -4,25 +4,11 @@ require "devflow"
|
|
4
4
|
|
5
5
|
DevFlow::TargetProcess.check_config!
|
6
6
|
|
7
|
-
|
7
|
+
args = ARGV[1..-1]
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
case ARGV[0]
|
10
|
+
when "pr"
|
11
|
+
DevFlow::Commands::PR.new(args)
|
11
12
|
else
|
12
|
-
|
13
|
-
assignments.each do |a|
|
14
|
-
puts "#{a[:id]}: #{a[:name]}"
|
15
|
-
end
|
16
|
-
selection = gets.chomp.to_i
|
17
|
-
|
18
|
-
assignment = assignments.find { |a| a[:id] == selection }
|
19
|
-
|
20
|
-
unless assignment
|
21
|
-
puts "No such task"
|
22
|
-
exit 1
|
23
|
-
end
|
13
|
+
DevFlow::Commands::Branch.new(args)
|
24
14
|
end
|
25
|
-
|
26
|
-
branch = "#{assignment[:id]}-#{DevFlow.branchify(assignment[:name])}"
|
27
|
-
|
28
|
-
`git checkout -b #{branch}`
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module DevFlow
|
2
|
+
module Commands
|
3
|
+
class Branch < DevFlow::Command
|
4
|
+
def call
|
5
|
+
unless current_assignment
|
6
|
+
puts "No such task"
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
branch = "#{assignment[:id]}-#{DevFlow.branchify(assignment[:name])}"
|
11
|
+
|
12
|
+
`git checkout -b #{branch}`
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def assignments
|
18
|
+
DevFlow::TargetProcess.assignments
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_assignment
|
22
|
+
@current_assignment =
|
23
|
+
if assignments.count == 1
|
24
|
+
assignments.first
|
25
|
+
else
|
26
|
+
puts "Multiple tasks in progress. Which one are you working on?"
|
27
|
+
assignments.each do |a|
|
28
|
+
puts "#{a[:id]}: #{a[:name]}"
|
29
|
+
end
|
30
|
+
selection = gets.chomp.to_i
|
31
|
+
|
32
|
+
assignments.find { |a| a[:id] == selection }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module DevFlow
|
2
|
+
module Commands
|
3
|
+
class PR < DevFlow::Command
|
4
|
+
STORY_URL_BASE = "#{DevFlow::TargetProcess::BASE_URI}/entity"
|
5
|
+
STORY_URL_PATTERN = /#{STORY_URL_BASE}\/(\d+)/
|
6
|
+
STORY_REGEX = /^(\d+)-(.*)/
|
7
|
+
FV_REGEX = /^fv-(.*)/
|
8
|
+
PR_TEMPLATES_PATHS = %w[
|
9
|
+
.github/PULL_REQUEST_TEMPLATE.md
|
10
|
+
]
|
11
|
+
|
12
|
+
def call
|
13
|
+
branch = `git rev-parse --abbrev-ref HEAD`
|
14
|
+
|
15
|
+
def titleize(str)
|
16
|
+
str.tr("-", " ").capitalize
|
17
|
+
end
|
18
|
+
|
19
|
+
case branch
|
20
|
+
when story_regex
|
21
|
+
story_id = $1
|
22
|
+
story_url = STORY_URL_BASE + "/" + story_id
|
23
|
+
title = "[#{story_id}] #{titleize($2)}"
|
24
|
+
when fv_regex
|
25
|
+
story_url = ""
|
26
|
+
title = "[FV] #{titleize($1)}"
|
27
|
+
else
|
28
|
+
story_url = ""
|
29
|
+
title = titleize(branch)
|
30
|
+
end
|
31
|
+
|
32
|
+
message = if (file = PR_TEMPLATES_PATHS.find { |p| File.exist?(p) })
|
33
|
+
<<~MESS
|
34
|
+
#{title}
|
35
|
+
|
36
|
+
#{File.read(file).gsub(STORY_URL_PATTERN, story_url)}
|
37
|
+
MESS
|
38
|
+
else
|
39
|
+
<<~MESS
|
40
|
+
#{title}
|
41
|
+
|
42
|
+
#{story_url}
|
43
|
+
MESS
|
44
|
+
end
|
45
|
+
|
46
|
+
puts message
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/devflow/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micke Lisinge
|
@@ -43,7 +43,6 @@ email:
|
|
43
43
|
- hi@micke.me
|
44
44
|
executables:
|
45
45
|
- devflow
|
46
|
-
- pr_template_builder
|
47
46
|
extensions: []
|
48
47
|
extra_rdoc_files: []
|
49
48
|
files:
|
@@ -53,9 +52,11 @@ files:
|
|
53
52
|
- LICENSE
|
54
53
|
- README.md
|
55
54
|
- bin/devflow
|
56
|
-
- bin/pr_template_builder
|
57
55
|
- devflow.gemspec
|
58
56
|
- lib/devflow.rb
|
57
|
+
- lib/devflow/command.rb
|
58
|
+
- lib/devflow/commands/branch.rb
|
59
|
+
- lib/devflow/commands/pr.rb
|
59
60
|
- lib/devflow/target_process.rb
|
60
61
|
- lib/devflow/target_process/error.rb
|
61
62
|
- lib/devflow/version.rb
|
data/bin/pr_template_builder
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "devflow"
|
4
|
-
|
5
|
-
DevFlow::TargetProcess.check_config!
|
6
|
-
|
7
|
-
story_url_base = "#{DevFlow::TargetProcess::BASE_URI}/entity"
|
8
|
-
story_url_pattern = /#{story_url_base}\/(\d+)/
|
9
|
-
story_regex = /^(\d+)-(.*)/
|
10
|
-
fv_regex = /^fv-(.*)/
|
11
|
-
branch = `git rev-parse --abbrev-ref HEAD`
|
12
|
-
pr_templates_paths = %w[
|
13
|
-
.github/PULL_REQUEST_TEMPLATE.md
|
14
|
-
]
|
15
|
-
|
16
|
-
def titleize(str)
|
17
|
-
str.tr("-", " ").capitalize
|
18
|
-
end
|
19
|
-
|
20
|
-
case branch
|
21
|
-
when story_regex
|
22
|
-
story_id = $1
|
23
|
-
story_url = story_url_base + "/" + story_id
|
24
|
-
title = "[#{story_id}] #{titleize($2)}"
|
25
|
-
when fv_regex
|
26
|
-
story_url = ""
|
27
|
-
title = "[FV] #{titleize($1)}"
|
28
|
-
else
|
29
|
-
story_url = ""
|
30
|
-
title = titleize(branch)
|
31
|
-
end
|
32
|
-
|
33
|
-
message = if (file = pr_templates_paths.find { |p| File.exist?(p) })
|
34
|
-
<<~MESS
|
35
|
-
#{title}
|
36
|
-
|
37
|
-
#{File.read(file).gsub(story_url_pattern, story_url)}
|
38
|
-
MESS
|
39
|
-
else
|
40
|
-
<<~MESS
|
41
|
-
#{title}
|
42
|
-
|
43
|
-
#{story_url}
|
44
|
-
MESS
|
45
|
-
end
|
46
|
-
|
47
|
-
puts message
|