gh_issues 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/gh_issues/cli.rb +32 -5
- data/lib/gh_issues/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: fae36a6c84d16d0c0c0f4ac8c9e41fc04db39e40
|
4
|
+
data.tar.gz: 4d9b3fdb9578c6ea647ed47d0d7df86fd25a09ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c857cc94d799e8bc7400df973f24260fd7f9b1ff2564d4337894ce4c2b26f061be9f40ba3e954324edc968e4665ab2052147b741e5071e09ab705013cdfdf9
|
7
|
+
data.tar.gz: 90c32db0c7aa286b16e3064e5fdcdbcce55ef2843c5e8bf20a73af2e96a6b6cf9fccd9121a96d95a761af08ac75b9145e9fccf1cea1db1c3ffa5a5000448f106
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/vigo/gh-issues.svg?branch=master)](https://travis-ci.org/vigo/gh-issues)
|
2
|
-
![Version](https://img.shields.io/badge/version-0.
|
2
|
+
![Version](https://img.shields.io/badge/version-0.3.0-yellow.svg)
|
3
3
|
|
4
4
|
# GitHub Issues
|
5
5
|
|
@@ -149,11 +149,13 @@ gh_issues list pyistanbul
|
|
149
149
|
|
150
150
|
### show
|
151
151
|
|
152
|
-
Show selected repo’s issues
|
152
|
+
Show selected repo’s issues or show current GitHub repo’s. If you are in a
|
153
|
+
folder with a git repo which has github **origin** you don’t need to type
|
154
|
+
repo name!
|
153
155
|
|
154
156
|
```bash
|
157
|
+
gh_issues show # you are in a git repo, origin is pointed to GitHub
|
155
158
|
gh_issues show pyistanbul/website
|
156
|
-
|
157
159
|
```
|
158
160
|
|
159
161
|
Here is the list:
|
@@ -177,7 +179,9 @@ If you pass **issue number** as parameter after repo name, you get the issue det
|
|
177
179
|
|
178
180
|
```bash
|
179
181
|
gh_issues show pyistanbul/website 48
|
182
|
+
gh_issues show 2 # you are in a git repo, origin is pointed to GitHub, issue #2
|
180
183
|
```
|
184
|
+
|
181
185
|
Result:
|
182
186
|
|
183
187
|
+------------+--------------------------------------------------------------------------------+
|
data/lib/gh_issues/cli.rb
CHANGED
@@ -82,19 +82,42 @@ module GhIssues
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
desc "show REPO_NAME [ISSUE_NUMBER]", "Show issues of REPO_NAME or ISSUE"
|
85
|
+
desc "show [REPO_NAME] [ISSUE_NUMBER]", "Show issues of REPO_NAME / current repo or ISSUE"
|
86
86
|
long_desc <<-LONGDESC
|
87
|
-
Show issues of selected repo
|
87
|
+
Show issues of selected repo or current repo if you are in a git repository
|
88
|
+
with GitHub origin pointed at. If you specify issue number, you'll get
|
88
89
|
details of that issue.\
|
89
90
|
|
91
|
+
$ gh_issues show # current dir/github repo
|
92
|
+
$ gh_issues show 2 # current dir/github repo issue 2
|
90
93
|
$ gh_issues show pyistanbul/website
|
91
94
|
$ gh_issues show pyistanbul/website 48
|
92
95
|
$ gh_issues show pyistanbul/website 48 --color
|
93
96
|
LONGDESC
|
94
|
-
def show(repo, issue_number=0)
|
97
|
+
def show(repo=nil, issue_number=0)
|
95
98
|
ENV['GH_ISSUES_COLORIZE'] = '1' if options[:color]
|
96
|
-
issue_number = issue_number.to_i
|
97
99
|
|
100
|
+
in_github_repo = false
|
101
|
+
current_repo = nil
|
102
|
+
origin_url=`git remote get-url origin 2>/dev/null`.strip
|
103
|
+
unless origin_url.empty?
|
104
|
+
in_github_repo = true if origin_url.split(':')[0] =~ /github.com/
|
105
|
+
end
|
106
|
+
|
107
|
+
current_repo = origin_url.split(':')[1].split('.')[0] if in_github_repo
|
108
|
+
|
109
|
+
unless repo
|
110
|
+
repo = current_repo if current_repo
|
111
|
+
else
|
112
|
+
if is_numeric?(repo)
|
113
|
+
issue_number = repo.to_i
|
114
|
+
repo = current_repo
|
115
|
+
end
|
116
|
+
end
|
117
|
+
issue_number = issue_number.to_i
|
118
|
+
|
119
|
+
puts "Listing current GitHub repo: #{repo}" if repo == current_repo
|
120
|
+
|
98
121
|
if issue_number > 0
|
99
122
|
issue = GhIssues.get_issue(repo, issue_number)
|
100
123
|
table = Terminal::Table.new do |t|
|
@@ -113,7 +136,7 @@ module GhIssues
|
|
113
136
|
now = Time.now
|
114
137
|
created_at_diff = TimeDifference.between(now, issue[:created_at]).in_days.to_i
|
115
138
|
updated_at_diff = TimeDifference.between(now, issue[:updated_at]).in_days.to_i
|
116
|
-
|
139
|
+
|
117
140
|
t.add_row [colorize("Created at", :yellow), "#{created_at} (#{created_at_diff} days ago)"]
|
118
141
|
t.add_row [colorize("Updated at", :yellow), "#{updated_at} (#{updated_at_diff} days ago)"]
|
119
142
|
if issue[:body].length > 0
|
@@ -146,6 +169,10 @@ module GhIssues
|
|
146
169
|
end
|
147
170
|
|
148
171
|
no_commands do
|
172
|
+
def is_numeric?(input)
|
173
|
+
input.to_f.to_s == input.to_s || input.to_i.to_s == input.to_s
|
174
|
+
end
|
175
|
+
|
149
176
|
def print_issue_list(data, **options)
|
150
177
|
sort_by = options[:sort_by]
|
151
178
|
sort_order = options[:sort_order]
|
data/lib/gh_issues/version.rb
CHANGED