prima-twig 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/twig-circle +2 -2
- data/bin/twig-open-pr +6 -2
- data/bin/twig-review +2 -2
- data/bin/twig-take-issue +78 -0
- data/lib/prima_twig.rb +7 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4235df66f116e82cec91485015227c678d9a528
|
4
|
+
data.tar.gz: 8e020b023f0d6f830d59e035f22251b69265c0c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d3429ed0d550da0eb7a40416bf89864820f3e1925471fc5cde6d19d68a799d939324e46a74276969173b967ba3653d4f3d393d63a9de025fd6db8a0db824945
|
7
|
+
data.tar.gz: e831f5e756253820e19955d2031d47713791739f4aaae61041fa9767e01d4d458e7c5e573826ad04986498cf41ce717016b5ed3837af19a7890cf35d7e48b344
|
data/bin/twig-circle
CHANGED
data/bin/twig-open-pr
CHANGED
@@ -43,7 +43,7 @@ class OpenPR
|
|
43
43
|
@prima = Prima.new
|
44
44
|
end
|
45
45
|
|
46
|
-
def execute
|
46
|
+
def execute!
|
47
47
|
unless @prima.gh.user_authenticated?
|
48
48
|
puts 'Non autenticato'
|
49
49
|
exit 1
|
@@ -97,12 +97,16 @@ class OpenPR
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def create_pull_request
|
100
|
+
current_branch_name = @prima.current_branch_name
|
100
101
|
title = ask('Titolo: ')
|
101
102
|
head = @prima.current_branch_name
|
102
103
|
base = 'dev'
|
103
104
|
body = ask('Body: ')
|
105
|
+
unless @prima.twig.get_branch_property(current_branch_name, 'issue').nil?
|
106
|
+
body << " close ##{@prima.twig.get_branch_property(current_branch_name, 'issue')}"
|
107
|
+
end
|
104
108
|
@prima.gh.create_pull_request @prima.repo_name, base, head, title, body
|
105
109
|
end
|
106
110
|
end
|
107
111
|
|
108
|
-
OpenPR.new.execute
|
112
|
+
OpenPR.new.execute!
|
data/bin/twig-review
CHANGED
@@ -42,7 +42,7 @@ class Review
|
|
42
42
|
@prima = Prima.new
|
43
43
|
end
|
44
44
|
|
45
|
-
def execute
|
45
|
+
def execute!
|
46
46
|
unless @prima.is_a_valid_branch?
|
47
47
|
puts "Il branch #{ @prima.current_branch_name } non può essere in review".red
|
48
48
|
exit 1
|
@@ -64,4 +64,4 @@ class Review
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
Review.new.execute
|
67
|
+
Review.new.execute!
|
data/bin/twig-take-issue
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require_relative '../lib/prima_twig.rb'
|
5
|
+
require 'colorize'
|
6
|
+
require 'highline/import'
|
7
|
+
|
8
|
+
def help_content
|
9
|
+
<<-HELP
|
10
|
+
|
11
|
+
twig-take-issue
|
12
|
+
===============
|
13
|
+
|
14
|
+
Takes an issue from github and open a branch for it
|
15
|
+
|
16
|
+
Synopsis
|
17
|
+
--------
|
18
|
+
|
19
|
+
twig take-issue
|
20
|
+
|
21
|
+
|
22
|
+
Subcommand for Twig: <http://rondevera.github.io/twig/>
|
23
|
+
Author: Matteo Giachino <https://github.com/matteosister>
|
24
|
+
|
25
|
+
HELP
|
26
|
+
end
|
27
|
+
|
28
|
+
args = ARGV.dup
|
29
|
+
|
30
|
+
if args.include?('--help')
|
31
|
+
puts help_content
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
class TakeIssue
|
37
|
+
def initialize
|
38
|
+
@prima = Prima.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def execute!
|
42
|
+
unless @prima.is_clean?
|
43
|
+
puts 'hai dei file non committati...non posso continuare'.red
|
44
|
+
#exit(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
issues = @prima.gh.list_issues('primait/prima')
|
48
|
+
issues.delete_if do |issue|
|
49
|
+
issue.pull_request?
|
50
|
+
end
|
51
|
+
|
52
|
+
issue_number = choose_issue(issues)
|
53
|
+
branch_name = ask('branch name: '.cyan)
|
54
|
+
branch_name << "-#{issue_number}"
|
55
|
+
branch_name = @prima.clean_branch_name branch_name
|
56
|
+
|
57
|
+
puts "creo branch con nome #{branch_name}"
|
58
|
+
@prima.rugged.branches.create(branch_name, 'master')
|
59
|
+
@prima.twig.set_branch_property(branch_name, 'issue', issue_number)
|
60
|
+
@prima.rugged.checkout(branch_name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def choose_issue(issues)
|
64
|
+
choose do |menu|
|
65
|
+
|
66
|
+
menu.prompt = 'Choose an issue: '.cyan
|
67
|
+
|
68
|
+
issues.each do |issue|
|
69
|
+
milestone = issue.milestone
|
70
|
+
msg = "##{issue.number} - #{issue.title}"
|
71
|
+
msg = "[#{milestone.title}] #{msg}" unless milestone.nil?
|
72
|
+
menu.choice(msg) {issue.number}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
TakeIssue.new.execute!
|
data/lib/prima_twig.rb
CHANGED
@@ -8,7 +8,7 @@ class Prima
|
|
8
8
|
REVIEW_LABEL='review'
|
9
9
|
GITHUB='github'
|
10
10
|
TRELLO='trello'
|
11
|
-
attr_reader :gh, :twig, :config
|
11
|
+
attr_reader :gh, :twig, :config, :rugged
|
12
12
|
|
13
13
|
def initialize
|
14
14
|
@twig = Twig.new(:read_options => true)
|
@@ -75,6 +75,12 @@ class Prima
|
|
75
75
|
"primait:#{ current_branch_name }"
|
76
76
|
end
|
77
77
|
|
78
|
+
def clean_branch_name(branch_name)
|
79
|
+
branch_name.gsub! /[^a-zA-Z0-9\-_]/, '_'
|
80
|
+
branch_name.gsub! /_+/, '_'
|
81
|
+
branch_name
|
82
|
+
end
|
83
|
+
|
78
84
|
# proxy di tutti i metodi a rugged
|
79
85
|
def method_missing(method)
|
80
86
|
@rugged.send method
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prima-twig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Giachino
|
@@ -101,12 +101,14 @@ executables:
|
|
101
101
|
- twig-circle
|
102
102
|
- twig-open-pr
|
103
103
|
- twig-review
|
104
|
+
- twig-take-issue
|
104
105
|
extensions: []
|
105
106
|
extra_rdoc_files: []
|
106
107
|
files:
|
107
108
|
- bin/twig-circle
|
108
109
|
- bin/twig-open-pr
|
109
110
|
- bin/twig-review
|
111
|
+
- bin/twig-take-issue
|
110
112
|
- lib/prima_twig.rb
|
111
113
|
homepage: http://rubygems.org/gems/prima-twig
|
112
114
|
licenses:
|