watson-ruby 1.0.5 → 1.0.6
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/Gemfile.lock +1 -1
- data/README.md +44 -23
- data/assets/defaultConf +6 -6
- data/bin/watson +1 -1
- data/lib/watson.rb +17 -17
- data/lib/watson/bitbucket.rb +52 -52
- data/lib/watson/command.rb +66 -66
- data/lib/watson/config.rb +73 -73
- data/lib/watson/fs.rb +15 -15
- data/lib/watson/github.rb +60 -60
- data/lib/watson/parser.rb +36 -31
- data/lib/watson/printer.rb +33 -33
- data/lib/watson/remote.rb +23 -23
- data/lib/watson/version.rb +2 -2
- data/spec/config_spec.rb +11 -11
- data/spec/fs_spec.rb +1 -1
- data/spec/helper_spec.rb +1 -1
- data/spec/parser_spec.rb +73 -9
- data/watson.gemspec +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44137e243624ca9f33b847d08d8a64789e89142d
|
4
|
+
data.tar.gz: 75194b81af02f48dfcdda8dea4e4ae4a00e42d87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3bece662ec2a55e7f7b25a1970537144eb22b6eda44d1e9f964141c2c5106f6092aa4c22ef6891c01017b8e9f4216aa3b9c7638f6d57d7eecb08ee934b13f20
|
7
|
+
data.tar.gz: be581a10fddb3dc38c23dfeb5063314c06dad67759a9fa928f5fba8af28f6d29fe2dc6d91d9e80242d1f5e8761c42751eff4375188c196eeaeadac8fc617ea47
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# watson-ruby
|
1
|
+
# watson-ruby [](https://travis-ci.org/nhmood/watson-ruby)
|
2
2
|
### an inline issue manager
|
3
|
-
[watson](http://goosecode.com/watson) ([mirror](http://nhmood.github.io/watson-ruby)) is a tool for creating and tracking bug reports, issues, and internal notes in code.
|
3
|
+
[watson](http://goosecode.com/watson) ([mirror](http://nhmood.github.io/watson-ruby)) is a tool for creating and tracking bug reports, issues, and internal notes in code.
|
4
4
|
It is avaliable in two flavors, [watson-ruby](http://github.com/nhmood/watson-ruby) and [watson-perl](http://github.com/nhmood/watson-perl)
|
5
5
|
|
6
6
|
### See watson in action [here](http://goosecode.com/watson) ([mirror](http://nhmood.github.io/watson-ruby))
|
@@ -8,7 +8,7 @@ It is avaliable in two flavors, [watson-ruby](http://github.com/nhmood/watson-ru
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
watson-ruby has been tested with **Ruby v2.0.0p247** and **RubyGems v2.0.3** (on **Arch Linux**)
|
11
|
-
watson-ruby requires the ```json``` gem
|
11
|
+
watson-ruby requires the ```json``` gem
|
12
12
|
|
13
13
|
### From Repo
|
14
14
|
watson-ruby is avaliable as a RubyGems ([link](https://rubygems.org/gems/watson-ruby)).
|
@@ -22,12 +22,33 @@ Or you can clone this repo and install with Rake
|
|
22
22
|
git clone https://github.com/nhmood/watson-ruby.git .
|
23
23
|
cd watson-ruby
|
24
24
|
bundle install
|
25
|
-
bundle exec rake
|
25
|
+
bundle exec rake
|
26
26
|
```
|
27
|
-
|
27
|
+
|
28
28
|
## Usage
|
29
29
|
For a quick idea of how to use watson, check out the [app demo](http://goosecode.com/watson)! ([mirror](http://nhmood.github.io/watson-ruby))
|
30
|
-
See below for a description of what all the command line arguments do.
|
30
|
+
See below for a description of what all the command line arguments do.
|
31
|
+
|
32
|
+
### Supported Languages
|
33
|
+
If you see something missing from the list please either file an issue or
|
34
|
+
submit a pull request (comment parsing happens in **lib/watson/paser.rb**)
|
35
|
+
|
36
|
+
- **C / C++**
|
37
|
+
- **Objective C**
|
38
|
+
- **C#**
|
39
|
+
- **Java**
|
40
|
+
- **Javascript**
|
41
|
+
- **PHP**
|
42
|
+
- **Go**
|
43
|
+
- **Scala**
|
44
|
+
- **Erlang**
|
45
|
+
- **Haskell**
|
46
|
+
- **Bash / Zsh**
|
47
|
+
- **Ruby**
|
48
|
+
- **Perl**
|
49
|
+
- **Python**
|
50
|
+
- **Coffeescript**
|
51
|
+
- **Clojure**
|
31
52
|
|
32
53
|
## Command line arguments
|
33
54
|
```
|
@@ -55,14 +76,14 @@ watson home page: <http://goosecode.com/projects/watson>
|
|
55
76
|
[goosecode] labs | 2012-2013
|
56
77
|
|
57
78
|
```
|
58
|
-
### All file/directory/tag related parameters support relative as well as absolute paths.
|
79
|
+
### All file/directory/tag related parameters support relative as well as absolute paths.
|
59
80
|
|
60
81
|
### -c, --context-lines [LINES]
|
61
82
|
This parameter specifies how many lines of context watson should include when posting issues to remote repos.
|
62
83
|
When this parameter is set from the command line, the .watsonrc config file is written with the value; the command line option effectively sets the default value for this feature in the current directory.
|
63
|
-
The default value is set to 15 (and can be found in the lib/watson/command.rb file).
|
84
|
+
The default value is set to 15 (and can be found in the lib/watson/command.rb file).
|
64
85
|
|
65
|
-
### -d, --dirs [DIRS]
|
86
|
+
### -d, --dirs [DIRS]
|
66
87
|
This parameter specifies which directories watson should parse through.
|
67
88
|
It should be followed by a space separated list of directories that should be parsed.
|
68
89
|
If watson is run without this parameter, the current directory is parsed.
|
@@ -74,20 +95,20 @@ It should be followed by a space separated list of files that should be parsed.
|
|
74
95
|
|
75
96
|
|
76
97
|
### -h, --help
|
77
|
-
This parameter displays the list of avaliable options for watson.
|
98
|
+
This parameter displays the list of avaliable options for watson.
|
78
99
|
|
79
100
|
|
80
101
|
### -i, --ignore [IGNORES]
|
81
102
|
This parameter specifies which files and directories watson should ignore when parsing.
|
82
103
|
It should be followed by a space separated list of files and/or directories to be ignored.
|
83
|
-
This parameter should be used as an opposite to -d/-f, when there are more files that should be parsed in a directory than should be ignored.
|
104
|
+
This parameter should be used as an opposite to -d/-f, when there are more files that should be parsed in a directory than should be ignored.
|
84
105
|
|
85
106
|
|
86
107
|
### -p, --parse-depth [PARSE_DEPTH]
|
87
108
|
This parameter specifies how deep watson should recursively parse directories.
|
88
109
|
The 'depth' is defined as how many levels deep from the top-most specified directory to parse.
|
89
110
|
If individual directories are passed with the -d (--dirs) flag, each will be parsed PARSE_DEPTH layers, regardless of their depth from the current directory.
|
90
|
-
If watson is run without this parameter, the parsing depth is unlimited and will search through all subdirectories found.
|
111
|
+
If watson is run without this parameter, the parsing depth is unlimited and will search through all subdirectories found.
|
91
112
|
|
92
113
|
|
93
114
|
### -r, --remote [GITHUB, BITBUCKET]
|
@@ -104,10 +125,10 @@ The tag currently supports any regular character and number combination, no spec
|
|
104
125
|
### -u, --update
|
105
126
|
This parameter is used to update remote repos with new issues.
|
106
127
|
watson **does not** post new issues by default therefore this parameter is required to push up to GitHub/Bitbucket.
|
107
|
-
watson **does** pull issue status by default, therefore you will always be notified of resolved issues on GitHub/Bitbucket.
|
128
|
+
watson **does** pull issue status by default, therefore you will always be notified of resolved issues on GitHub/Bitbucket.
|
108
129
|
|
109
130
|
### -v, --version
|
110
|
-
This parameter displays the current version of watson you are running.
|
131
|
+
This parameter displays the current version of watson you are running.
|
111
132
|
|
112
133
|
|
113
134
|
## .watsonrc
|
@@ -117,30 +138,30 @@ The .watsonrc is placed in every directory that watson is run from as opposed to
|
|
117
138
|
For example, a C/C++ project might want to look in src/ and ignore obj/ whereas a Ruby project might want to look in lib/ and ignore assets/.
|
118
139
|
|
119
140
|
The .watsonrc file is fairly straightforward...
|
120
|
-
**[dirs]** - This is a newline separated list of directories to look in while parsing.
|
141
|
+
**[dirs]** - This is a newline separated list of directories to look in while parsing.
|
121
142
|
|
122
|
-
**[tags]** - This is a newline separated list of tags to look for while parsing.
|
143
|
+
**[tags]** - This is a newline separated list of tags to look for while parsing.
|
123
144
|
|
124
|
-
**[ignore]** - This is a newline separated list of files / folders to ignore while parsing.
|
125
|
-
This supports wildcard type selecting by providing .filename (no * required)
|
145
|
+
**[ignore]** - This is a newline separated list of files / folders to ignore while parsing.
|
146
|
+
This supports wildcard type selecting by providing .filename (no * required)
|
126
147
|
|
127
|
-
**[context_depth]** - This value determines how many lines of context should be grabbed for each issue when posting to a remote.
|
148
|
+
**[context_depth]** - This value determines how many lines of context should be grabbed for each issue when posting to a remote.
|
128
149
|
|
129
150
|
**[(github/bitbucket)]** - If a remote is established, the API key for the corresponding remote is stored here.
|
130
|
-
Currently, OAuth has yet to be implemented for Bitbucket so the Bitbucket username is stored here.
|
151
|
+
Currently, OAuth has yet to be implemented for Bitbucket so the Bitbucket username is stored here.
|
131
152
|
|
132
153
|
**[(github/bitbucket)_repo]** - The repo name / path is stored here.
|
133
154
|
|
134
|
-
The remote related .watsonrc options shouldn't need to be edited manually, as they are automatically populated when the -r, --remote setup is called.
|
155
|
+
The remote related .watsonrc options shouldn't need to be edited manually, as they are automatically populated when the -r, --remote setup is called.
|
135
156
|
|
136
157
|
## Special Thanks
|
137
158
|
Special thanks to [@samirahmed](http://github.com/samirahmed) for his super Ruby help and encouraging the Ruby port!
|
138
159
|
Special thanks to [@eugenekolo](http://twitter.com/eugenekolo) [[email](eugenek@bu.edu)] for his super Perl help!
|
139
|
-
Special thanks to [@crowell](http://github.com/crowell) for testing out watson-ruby!
|
160
|
+
Special thanks to [@crowell](http://github.com/crowell) for testing out watson-ruby!
|
140
161
|
|
141
162
|
## FAQ
|
142
163
|
- **Why Ruby?**
|
143
|
-
I wanted to learn Ruby and this seemed like a pretty decent project.
|
164
|
+
I wanted to learn Ruby and this seemed like a pretty decent project.
|
144
165
|
|
145
166
|
- **Why is the Ruby version different from the Perl version?**
|
146
167
|
The Ruby version was developed after the Perl version was made. Because of this, it was a lot easier to add on features that were thought of while/after making the Perl version as the plumbing was still being setup.
|
data/assets/defaultConf
CHANGED
data/bin/watson
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
# [review] - Using own funky path loading because traditional way seems wrong?
|
5
|
-
# Commented out version is traditional, seen in many apps. If you use that and
|
5
|
+
# Commented out version is traditional, seen in many apps. If you use that and
|
6
6
|
# look at load_path you get path/../lib (I'd expect those to be separate?)
|
7
7
|
# My funky version adds path/., path/bin, path/assets separately
|
8
8
|
# Maybe I don't get how the load path is supposed to look though...
|
data/lib/watson.rb
CHANGED
@@ -11,59 +11,59 @@ module Watson
|
|
11
11
|
# [todo] - Replace all regex parentheses() with brackets[] if not matching
|
12
12
|
# Was using () to group things together for syntax instead of []
|
13
13
|
# Replace so we can get cleaner matches and don't need to keep track of matches
|
14
|
-
|
14
|
+
|
15
15
|
# [todo] - Change debug_print to provide its own \n
|
16
|
-
|
17
|
-
# [todo] - Add ability to pass "IDENTIFY" to debug_print to auto print method entry info
|
18
|
-
|
16
|
+
|
17
|
+
# [todo] - Add ability to pass "IDENTIFY" to debug_print to auto print method entry info
|
18
|
+
|
19
19
|
# [todo] - Make sure all methods have proper return at end
|
20
|
-
|
20
|
+
|
21
21
|
# [review] - Method input arg always renamed from arg to _arg inside method, change this?
|
22
|
-
# Not sure if I should just make input arg _arg or if explicit _ is useful
|
23
|
-
|
22
|
+
# Not sure if I should just make input arg _arg or if explicit _ is useful
|
23
|
+
|
24
24
|
# [todo] - Add option to save output to specified file
|
25
25
|
# [todo] - Replace Identify line in each method with method_added call
|
26
26
|
# http://ruby-doc.org/core-2.0.0/Module.html#method-i-method_added
|
27
27
|
|
28
|
-
# Separate ON and OFF so we can force state and still let
|
28
|
+
# Separate ON and OFF so we can force state and still let
|
29
29
|
# individual classes have some control over their prints
|
30
30
|
|
31
31
|
# Global flag to turn ON debugging across all files
|
32
32
|
GLOBAL_DEBUG_ON = false
|
33
33
|
# Gllobal flag to turn OFF debugging across all files
|
34
|
-
GLOBAL_DEBUG_OFF = false
|
34
|
+
GLOBAL_DEBUG_OFF = false
|
35
35
|
|
36
36
|
# [review] - Not sure if module_function is proper way to scope
|
37
37
|
# I want to be able to call debug_print without having to use the scope
|
38
|
-
# operator (Watson::Printer.debug_print) so it is defined here as a
|
38
|
+
# operator (Watson::Printer.debug_print) so it is defined here as a
|
39
39
|
# module_function instead of having it in the Printer class
|
40
40
|
# Gets included into every class individually
|
41
41
|
module_function
|
42
|
-
|
42
|
+
|
43
43
|
###########################################################
|
44
|
-
# Global debug print that prints based on local file DEBUG flag as well as GLOBAL debug flag
|
44
|
+
# Global debug print that prints based on local file DEBUG flag as well as GLOBAL debug flag
|
45
45
|
def debug_print(msg)
|
46
46
|
# [todo] - If input msg is a Hash, use pp to dump it
|
47
47
|
|
48
|
-
# Print only if DEBUG flag of calling class is true OR
|
48
|
+
# Print only if DEBUG flag of calling class is true OR
|
49
49
|
# GLOBAL_DEBUG_ON of Watson module (defined above) is true
|
50
50
|
# AND GLOBAL_DEBUG_OFF of Watson module (Defined above) is false
|
51
51
|
|
52
52
|
# Sometimes we call debug_print from a static method (class << self)
|
53
|
-
# and other times from a class method, and ::DEBUG is accessed differently
|
53
|
+
# and other times from a class method, and ::DEBUG is accessed differently
|
54
54
|
# from a class vs object, so lets take care of that
|
55
55
|
_DEBUG = (self.is_a? Class) ? self::DEBUG : self.class::DEBUG
|
56
56
|
|
57
57
|
print "=> #{msg}" if ( (_DEBUG == true || GLOBAL_DEBUG_ON == true) && (GLOBAL_DEBUG_OFF == false))
|
58
|
-
end
|
58
|
+
end
|
59
59
|
|
60
60
|
|
61
61
|
###########################################################
|
62
|
-
# Perform system check to see if we are able to use unix less for printing
|
62
|
+
# Perform system check to see if we are able to use unix less for printing
|
63
63
|
def check_less
|
64
64
|
# Check if system has less (so we can print out to it to allow scrolling)
|
65
65
|
# [todo] - Implement this scrolling thing inside watson with ncurses
|
66
|
-
return system("which less > /dev/null 2>&1")
|
66
|
+
return system("which less > /dev/null 2>&1")
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
data/lib/watson/bitbucket.rb
CHANGED
@@ -4,29 +4,29 @@ module Watson
|
|
4
4
|
# Contains all necessary methods to obtain access to, get issue list,
|
5
5
|
# and post issues to Bitbucket
|
6
6
|
class Bitbucket
|
7
|
-
|
7
|
+
|
8
8
|
# Debug printing for this class
|
9
|
-
DEBUG = false
|
9
|
+
DEBUG = false
|
10
10
|
|
11
11
|
class << self
|
12
12
|
|
13
13
|
# [todo] - Allow closing of issues from watson? Don't like that idea but maybe
|
14
14
|
# [todo] - Wrap Bitbucket password grabbing into separate method
|
15
|
-
|
15
|
+
|
16
16
|
# Include for debug_print
|
17
17
|
include Watson
|
18
|
-
|
19
|
-
#############################################################################
|
18
|
+
|
19
|
+
#############################################################################
|
20
20
|
# Setup remote access to Bitbucket
|
21
21
|
# Get Username, Repo, and PW and perform necessary HTTP calls to check validity
|
22
22
|
def setup(config)
|
23
|
-
|
23
|
+
|
24
24
|
# Identify method entry
|
25
25
|
debug_print "#{ self.class } : #{ __method__ }\n"
|
26
|
-
|
26
|
+
|
27
27
|
Printer.print_status "+", GREEN
|
28
28
|
print BOLD + "Attempting to access Bitbucket...\n" + RESET
|
29
|
-
|
29
|
+
|
30
30
|
# Check config to make sure no previous repo info exists
|
31
31
|
unless config.bitbucket_api.empty? && config.bitbucket_repo.empty?
|
32
32
|
Printer.print_status "!", RED
|
@@ -52,7 +52,7 @@ module Watson
|
|
52
52
|
# [todo] - Bitbucket OAuth not implemented yet so warn user about HTTP Auth
|
53
53
|
# Bitbucket doesn't have nonOAuth flow that GitHub does :(
|
54
54
|
# Even if I use OAuth lib, still need to validate from webview which is lame
|
55
|
-
Printer.print_status "!", RED
|
55
|
+
Printer.print_status "!", RED
|
56
56
|
print BOLD + "Bitbucket OAuth not implemented yet.\n" + RESET;
|
57
57
|
print " Basic HTTP Auth in use, will request PW entry every time.\n\n"
|
58
58
|
|
@@ -70,7 +70,7 @@ module Watson
|
|
70
70
|
print "\n"
|
71
71
|
|
72
72
|
# Get repo information, if blank give error
|
73
|
-
Printer.print_status "!", YELLOW
|
73
|
+
Printer.print_status "!", YELLOW
|
74
74
|
print BOLD + "Repo information required\n" + RESET
|
75
75
|
print " Please provide owner that repo is under followed by repo name\n"
|
76
76
|
print " e.g. owner: nhmood, repo: watson (case sensitive)\n"
|
@@ -109,11 +109,11 @@ module Watson
|
|
109
109
|
return false
|
110
110
|
end
|
111
111
|
|
112
|
-
# HTTP Request to check if Repo exists and user has access
|
113
|
-
# http://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs
|
112
|
+
# HTTP Request to check if Repo exists and user has access
|
113
|
+
# http://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs
|
114
114
|
|
115
|
-
# Create options hash to pass to Remote::http_call
|
116
|
-
# Endpoint for accessing Repo as User with SSL
|
115
|
+
# Create options hash to pass to Remote::http_call
|
116
|
+
# Endpoint for accessing Repo as User with SSL
|
117
117
|
# Basic auth with user input
|
118
118
|
opts = {:url => "https://bitbucket.org/api/1.0/repositories/#{_owner}/#{_repo}",
|
119
119
|
:ssl => true,
|
@@ -136,9 +136,9 @@ module Watson
|
|
136
136
|
print " Check that credentials are correct and repository exists under user\n"
|
137
137
|
print " Status: #{ _resp.code } - #{ _resp.message }\n\n"
|
138
138
|
return false
|
139
|
-
end
|
139
|
+
end
|
140
|
+
|
140
141
|
|
141
|
-
|
142
142
|
# No OAuth for Bitbucket yet so just store username in api for config
|
143
143
|
# This will let us just prompt for PW
|
144
144
|
config.bitbucket_api = _username
|
@@ -147,7 +147,7 @@ module Watson
|
|
147
147
|
debug_print " \n"
|
148
148
|
|
149
149
|
# All setup has been completed, need to update RC
|
150
|
-
# Call config updater/writer from @config to write config
|
150
|
+
# Call config updater/writer from @config to write config
|
151
151
|
debug_print "Updating config with new Bitbucket info\n"
|
152
152
|
config.update_conf("bitbucket_api", "bitbucket_repo")
|
153
153
|
|
@@ -160,17 +160,17 @@ module Watson
|
|
160
160
|
|
161
161
|
return true
|
162
162
|
|
163
|
-
end
|
163
|
+
end
|
164
164
|
|
165
165
|
|
166
166
|
###########################################################
|
167
|
-
# Get all remote Bitbucket issues and store into Config container class
|
167
|
+
# Get all remote Bitbucket issues and store into Config container class
|
168
168
|
def get_issues(config)
|
169
169
|
|
170
170
|
# Identify method entry
|
171
171
|
debug_print "#{ self.class } : #{ __method__ }\n"
|
172
172
|
|
173
|
-
# Only attempt to get issues if API is specified
|
173
|
+
# Only attempt to get issues if API is specified
|
174
174
|
if config.bitbucket_api.empty?
|
175
175
|
debug_print "No API found, this shouldn't be called...\n"
|
176
176
|
return false
|
@@ -182,7 +182,7 @@ module Watson
|
|
182
182
|
Printer.print_status "!", YELLOW
|
183
183
|
print BOLD + "Bitbucket password required for remote checking/posting.\n" + RESET
|
184
184
|
print " Password: "
|
185
|
-
|
185
|
+
|
186
186
|
# Block output to tty to prevent PW showing, Linux/Unix only :(
|
187
187
|
system "stty -echo"
|
188
188
|
_password = $stdin.gets.chomp
|
@@ -199,7 +199,7 @@ module Watson
|
|
199
199
|
|
200
200
|
|
201
201
|
# Get all open tickets (anything but resolved)
|
202
|
-
# Create options hash to pass to Remote::http_call
|
202
|
+
# Create options hash to pass to Remote::http_call
|
203
203
|
# Issues URL for Bitbucket + SSL
|
204
204
|
opts = {:url => "https://bitbucket.org/api/1.0/repositories/#{ config.bitbucket_repo }/issues?status=!resolved",
|
205
205
|
:ssl => true,
|
@@ -209,8 +209,8 @@ module Watson
|
|
209
209
|
}
|
210
210
|
|
211
211
|
_json, _resp = Watson::Remote.http_call(opts)
|
212
|
-
|
213
|
-
|
212
|
+
|
213
|
+
|
214
214
|
# Check response to validate repo access
|
215
215
|
if _resp.code != "200"
|
216
216
|
Printer.print_status "x", RED
|
@@ -224,19 +224,19 @@ module Watson
|
|
224
224
|
return false
|
225
225
|
end
|
226
226
|
|
227
|
-
|
227
|
+
|
228
228
|
|
229
229
|
config.bitbucket_issues[:open] = _json["issues"].empty? ? Hash.new : _json["issues"]
|
230
230
|
config.bitbucket_valid = true
|
231
|
-
|
231
|
+
|
232
232
|
# Get all closed tickets
|
233
|
-
# Create options hash to pass to Remote::http_call
|
233
|
+
# Create options hash to pass to Remote::http_call
|
234
234
|
# Issues URL for Bitbucket + SSL
|
235
235
|
opts = {:url => "https://bitbucket.org/api/1.0/repositories/#{ config.bitbucket_repo }/issues?status=resolved",
|
236
236
|
:ssl => true,
|
237
237
|
:method => "GET",
|
238
238
|
:basic_auth => [config.bitbucket_api, config.bitbucket_pw],
|
239
|
-
:verbose => false
|
239
|
+
:verbose => false
|
240
240
|
}
|
241
241
|
|
242
242
|
_json, _resp = Watson::Remote.http_call(opts)
|
@@ -246,31 +246,31 @@ module Watson
|
|
246
246
|
if _resp.code != "200"
|
247
247
|
Printer.print_status "x", RED
|
248
248
|
print BOLD + "Unable to get closed issues.\n" + RESET
|
249
|
-
print " Since the open issues were obtained, something is probably wrong and you should file a bug report or something...\n"
|
249
|
+
print " Since the open issues were obtained, something is probably wrong and you should file a bug report or something...\n"
|
250
250
|
print " Status: #{ _resp.code } - #{ _resp.message }\n"
|
251
|
-
|
251
|
+
|
252
252
|
debug_print "Bitbucket invalid, setting config var\n"
|
253
253
|
config.bitbucket_valid = false
|
254
254
|
return false
|
255
255
|
end
|
256
256
|
|
257
|
-
config.bitbucket_issues[:closed] = _json["issues"].empty? ? Hash.new : _json["issues"]
|
257
|
+
config.bitbucket_issues[:closed] = _json["issues"].empty? ? Hash.new : _json["issues"]
|
258
258
|
config.bitbucket_valid = true
|
259
259
|
return true
|
260
|
-
end
|
260
|
+
end
|
261
261
|
|
262
262
|
|
263
263
|
###########################################################
|
264
|
-
# Post given issue to remote Bitbucket repo
|
264
|
+
# Post given issue to remote Bitbucket repo
|
265
265
|
def post_issue(issue, config)
|
266
266
|
# [todo] - Better way to identify/compare remote->local issues than md5
|
267
267
|
# Current md5 based on some things that easily can change, need better ident
|
268
268
|
|
269
269
|
# Identify method entry
|
270
270
|
debug_print "#{self.class} : #{__method__}\n"
|
271
|
-
|
272
|
-
|
273
|
-
# Only attempt to get issues if API is specified
|
271
|
+
|
272
|
+
|
273
|
+
# Only attempt to get issues if API is specified
|
274
274
|
if config.bitbucket_api.empty?
|
275
275
|
debug_print "No API found, this shouldn't be called...\n"
|
276
276
|
return false
|
@@ -283,16 +283,16 @@ module Watson
|
|
283
283
|
# call exec and turn it into a real hash for parsing in watson
|
284
284
|
# Makes watson code cleaner but not as readable comment on GitHub...?
|
285
285
|
debug_print "Checking open issues to see if already posted\n"
|
286
|
-
config.bitbucket_issues[:open].each do | _open |
|
286
|
+
config.bitbucket_issues[:open].each do | _open |
|
287
287
|
if _open["content"].include?(issue[:md5])
|
288
288
|
debug_print "Found in #{ _open["title"] }, not posting\n"
|
289
289
|
return false
|
290
290
|
end
|
291
291
|
debug_print "Did not find in #{_open["title"]}\n"
|
292
|
-
end
|
293
|
-
|
292
|
+
end
|
293
|
+
|
294
294
|
debug_print "Checking closed issues to see if already posted\n"
|
295
|
-
config.bitbucket_issues[:closed].each do | _closed |
|
295
|
+
config.bitbucket_issues[:closed].each do | _closed |
|
296
296
|
if _closed["content"].include?(issue[:md5])
|
297
297
|
debug_print "Found in #{ _closed["title"] }, not posting\n"
|
298
298
|
return false
|
@@ -307,7 +307,7 @@ module Watson
|
|
307
307
|
Printer.print_status "!", YELLOW
|
308
308
|
print BOLD + "Bitbucket password required for remote checking/posting.\n" + RESET
|
309
309
|
print " Password: "
|
310
|
-
|
310
|
+
|
311
311
|
# Block output to tty to prevent PW showing, Linux/Unix only :(
|
312
312
|
print "Password: "
|
313
313
|
system "stty -echo"
|
@@ -325,17 +325,17 @@ module Watson
|
|
325
325
|
|
326
326
|
|
327
327
|
|
328
|
-
|
328
|
+
|
329
329
|
# We didn't find the md5 for this issue in the open or closed issues, so safe to post
|
330
|
-
|
330
|
+
|
331
331
|
# Create the body text for the issue here, too long to fit nicely into opts hash
|
332
332
|
# [review] - Only give relative path for privacy when posted
|
333
333
|
_body = "__filename__ : #{ issue[:path] } \n" +
|
334
|
-
"__line #__ : #{ issue[:line_number] } \n" +
|
334
|
+
"__line #__ : #{ issue[:line_number] } \n" +
|
335
335
|
"__tag__ : #{ issue[:tag] } \n" +
|
336
336
|
"__md5__ : #{ issue[:md5] } \n\n" +
|
337
337
|
"#{ issue[:context].join }"
|
338
|
-
|
338
|
+
|
339
339
|
# Create option hash to pass to Remote::http_call
|
340
340
|
# Issues URL for GitHub + SSL
|
341
341
|
# No tag or label concept in Bitbucket unfortunately :(
|
@@ -345,25 +345,25 @@ module Watson
|
|
345
345
|
:basic_auth => [config.bitbucket_api, config.bitbucket_pw],
|
346
346
|
:data => [{"title" => issue[:title] + " [#{ issue[:path] }]",
|
347
347
|
"content" => _body }],
|
348
|
-
:verbose => false
|
348
|
+
:verbose => false
|
349
349
|
}
|
350
350
|
|
351
351
|
_json, _resp = Watson::Remote.http_call(opts)
|
352
|
-
|
353
|
-
|
352
|
+
|
353
|
+
|
354
354
|
# Check response to validate repo access
|
355
355
|
# Shouldn't be necessary if we passed the last check but just to be safe
|
356
356
|
if _resp.code != "200"
|
357
357
|
Printer.print_status "x", RED
|
358
358
|
print BOLD + "Post unsuccessful. \n" + RESET
|
359
|
-
print " Since the open issues were obtained earlier, something is probably wrong and you should let someone know...\n"
|
359
|
+
print " Since the open issues were obtained earlier, something is probably wrong and you should let someone know...\n"
|
360
360
|
print " Status: #{ _resp.code } - #{ _resp.message }\n"
|
361
361
|
return false
|
362
362
|
end
|
363
|
-
|
364
|
-
return true
|
363
|
+
|
364
|
+
return true
|
365
365
|
end
|
366
|
-
|
366
|
+
|
367
367
|
end
|
368
368
|
|
369
369
|
|