face_control 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +48 -34
- data/Rakefile +0 -1
- data/face_control.gemspec +1 -2
- data/lib/face_control/checkers/rubocop.rb +1 -1
- data/lib/face_control/cli.rb +1 -10
- data/lib/stash/config.rb +6 -2
- data/lib/stash/server.rb +18 -4
- metadata +7 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ba514fb93a1dfb2754c39133e292bf4465f14a91c740d23d1d41b578f7eb535e
|
4
|
+
data.tar.gz: b918ef667cef7b3f735990f278871c2f5150498c692ba3931d588234cf6bdf3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ff9a7e50d7b3adad8705b57ce83094567ed66832d8886e7299661b703e79a2ed1924d32ac7b3e8ae1dbfd22c279cba67cf8548ede752d4f17f55f8e4c5fdde
|
7
|
+
data.tar.gz: e9ccb42632591b28a0a50fb0d622d5fcb72c7dff13f20befe6d34051939a8dcc1a40f607260c5f840a1c2b4273d94f6c68713fe865f366178cbf37cd3ea29d4c
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# Face Control
|
2
|
+
|
1
3
|
[![Gem Version](https://img.shields.io/gem/v/face_control.svg)](https://rubygems.org/gems/face_control)
|
2
4
|
[![Code Climate](https://img.shields.io/codeclimate/github/vassilevsky/face_control.svg)](https://codeclimate.com/github/vassilevsky/face_control/code)
|
3
5
|
[![Vexor](https://ci.vexor.io/projects/126da196-c8e6-46f0-8bc7-b5f8f4b49732/status.svg)](https://ci.vexor.io/ui/projects/126da196-c8e6-46f0-8bc7-b5f8f4b49732/builds)
|
4
6
|
[![Coveralls](https://img.shields.io/coveralls/vassilevsky/face_control.svg)](https://coveralls.io/github/vassilevsky/face_control)
|
5
7
|
[![VersionEye](https://img.shields.io/versioneye/d/ruby/face_control.svg)](https://www.versioneye.com/ruby/face_control)
|
6
8
|
|
7
|
-
# Face Control
|
8
|
-
|
9
9
|
Run static analysis of pull requests in [Bitbucket Server][] (formerly Stash)
|
10
10
|
and comment on problems in added lines.
|
11
11
|
|
@@ -16,61 +16,75 @@ Inspired by [Hound][].
|
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
|
-
|
19
|
+
```bash
|
20
|
+
gem install face_control
|
21
|
+
```
|
20
22
|
|
21
|
-
You also need to have CoffeeLint installed and available in PATH
|
23
|
+
You also need to have CoffeeLint installed and available in `PATH`.
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
```bash
|
28
|
+
face-control <project> <repository> <pull_request_id>
|
29
|
+
```
|
30
|
+
|
31
|
+
It's natural to run this on a continuous integration server (see “[Example](#example)” below).
|
26
32
|
|
27
|
-
|
28
|
-
|
33
|
+
If you don't want to receive RuboCop comments with certain severity level,
|
34
|
+
pass the severity in the `--skip-severity` option like so:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
face-control --skip-severity convention <project> <repository> <pull_request_id>
|
38
|
+
```
|
29
39
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
* Refspec:
|
40
|
+
Instead of `--skip-severity` you can use just `-S`.
|
41
|
+
|
42
|
+
You can also pass multiple severity levels as a comma-separated list:
|
34
43
|
|
35
|
-
|
44
|
+
```bash
|
45
|
+
face-control -S convention,refactor <project> <repository> <pull_request_id>
|
46
|
+
```
|
36
47
|
|
37
|
-
|
48
|
+
`face-control` uses the same configuration file (`~/.stashconfig.yml`)
|
49
|
+
as the official [Bitbucket Server Command Line Tools][]
|
50
|
+
to connect to your Stash instance.
|
38
51
|
|
39
|
-
|
40
|
-
* Branch Specifier:
|
52
|
+
## Example
|
41
53
|
|
42
|
-
|
54
|
+
Here's a [Jenkins][] project setup as an example:
|
43
55
|
|
44
|
-
|
56
|
+
_Source Code Management → Git → Repositories → Refspec:_
|
45
57
|
|
46
|
-
|
47
|
-
|
48
|
-
|
58
|
+
```
|
59
|
+
+refs/pull-requests/*:refs/remotes/origin/pull-requests/*
|
60
|
+
```
|
49
61
|
|
50
|
-
|
62
|
+
It makes Jenkins fetch otherwise ignored Stash-created branches.
|
51
63
|
|
52
|
-
|
53
|
-
npm install -g coffeelint
|
64
|
+
_Source Code Management → Git → Branches to build → Branch Specifier:_
|
54
65
|
|
55
|
-
|
66
|
+
```
|
67
|
+
origin/pull-requests/*/merge
|
68
|
+
```
|
56
69
|
|
57
|
-
|
58
|
-
pass the severity in the `--skip-severity` option like so:
|
70
|
+
Merge results of open non-conflicting pull requests.
|
59
71
|
|
60
|
-
|
72
|
+
_Build → Execute shell → Command:_
|
61
73
|
|
62
|
-
|
63
|
-
|
74
|
+
```bash
|
75
|
+
export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
|
64
76
|
|
65
|
-
|
77
|
+
gem install rubocop face_control
|
78
|
+
npm install -g coffeelint
|
66
79
|
|
67
|
-
|
68
|
-
|
69
|
-
to connect to your Stash instance.
|
80
|
+
face-control <project> <repository> $PULL_REQUEST_ID
|
81
|
+
```
|
70
82
|
|
71
83
|
## Etymology
|
72
84
|
|
73
|
-
[Face control][] in Wikipedia
|
85
|
+
[Face control][] in Wikipedia.
|
86
|
+
|
87
|
+
[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)
|
74
88
|
|
75
89
|
[Hound]: https://houndci.com
|
76
90
|
[Bitbucket Server]: https://www.atlassian.com/software/bitbucket/server
|
data/Rakefile
CHANGED
data/face_control.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'face_control'
|
3
|
-
spec.version = '0.9.
|
3
|
+
spec.version = '0.9.1'
|
4
4
|
spec.authors = ['Ilya Vassilevsky']
|
5
5
|
spec.email = ['vassilevsky@gmail.com']
|
6
6
|
|
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.add_runtime_dependency 'rubocop'
|
17
17
|
spec.add_runtime_dependency 'httparty'
|
18
18
|
|
19
|
-
spec.add_development_dependency 'bundler', '~> 1.8'
|
20
19
|
spec.add_development_dependency 'rake', '~> 10.0'
|
21
20
|
spec.add_development_dependency 'minitest', '~> 5.8'
|
22
21
|
spec.add_development_dependency 'minitest-reporters', '~> 1.0'
|
@@ -58,7 +58,7 @@ module FaceControl
|
|
58
58
|
def style_guide_url(offense)
|
59
59
|
cop_name = offense['cop_name']
|
60
60
|
config = ::RuboCop::ConfigLoader.default_configuration
|
61
|
-
::RuboCop::Cop::MessageAnnotator.new(config, config.for_cop(cop_name), {}).urls.first
|
61
|
+
::RuboCop::Cop::MessageAnnotator.new(config, cop_name, config.for_cop(cop_name), {}).urls.first
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/face_control/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module FaceControl
|
|
9
9
|
def run
|
10
10
|
logger = Logger.new(STDOUT)
|
11
11
|
project, repository, pull_request_id, ignored_severities = arguments
|
12
|
-
pull_request =
|
12
|
+
pull_request = Stash::Config.new.server(logger).repository(project, repository).pull_request(pull_request_id)
|
13
13
|
|
14
14
|
logger.info('Running checkers...')
|
15
15
|
comments = check(pull_request, ignored_severities, logger)
|
@@ -60,14 +60,5 @@ module FaceControl
|
|
60
60
|
puts e.message
|
61
61
|
exit(1)
|
62
62
|
end
|
63
|
-
|
64
|
-
def pull_request(project, repository, pull_request_id, logger)
|
65
|
-
@pull_request ||= begin
|
66
|
-
config = Stash::Config.new
|
67
|
-
server = Stash::Server.new(config.host, config.user, config.password, logger)
|
68
|
-
repository = server.repository(project, repository)
|
69
|
-
repository.pull_request(pull_request_id)
|
70
|
-
end
|
71
|
-
end
|
72
63
|
end
|
73
64
|
end
|
data/lib/stash/config.rb
CHANGED
@@ -8,6 +8,12 @@ module Stash
|
|
8
8
|
fail "#{@config_file} does not exist" unless File.exist?(@config_file)
|
9
9
|
end
|
10
10
|
|
11
|
+
def server(logger = nil)
|
12
|
+
Server.new(host, user, password, logger)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
11
17
|
def host
|
12
18
|
config['stash_url']
|
13
19
|
end
|
@@ -20,8 +26,6 @@ module Stash
|
|
20
26
|
config['password']
|
21
27
|
end
|
22
28
|
|
23
|
-
private
|
24
|
-
|
25
29
|
def config
|
26
30
|
@config ||= YAML.load_file(@config_file)
|
27
31
|
end
|
data/lib/stash/server.rb
CHANGED
@@ -3,6 +3,8 @@ require 'stash/repository'
|
|
3
3
|
|
4
4
|
module Stash
|
5
5
|
class Server
|
6
|
+
class CommunicationError < StandardError; end
|
7
|
+
|
6
8
|
attr_accessor :root_uri, :user, :password, :logger
|
7
9
|
|
8
10
|
def initialize(root_uri, user, password, logger = nil)
|
@@ -19,14 +21,18 @@ module Stash
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def get(path)
|
22
|
-
|
23
|
-
|
24
|
+
with_error_handling do
|
25
|
+
logged('Response') do
|
26
|
+
HTTParty.get(endpoint + path, auth.merge(logging))
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
31
|
def post(path, data)
|
28
|
-
|
29
|
-
|
32
|
+
with_error_handling do
|
33
|
+
logged('Response') do
|
34
|
+
HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging))
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
@@ -73,5 +79,13 @@ module Stash
|
|
73
79
|
{}
|
74
80
|
end
|
75
81
|
end
|
82
|
+
|
83
|
+
def with_error_handling
|
84
|
+
yield.tap do |response|
|
85
|
+
unless response.success?
|
86
|
+
fail CommunicationError, 'Stash responded with an error'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
76
90
|
end
|
77
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: face_control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Vassilevsky
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.8'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.8'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +122,7 @@ dependencies:
|
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '0.8'
|
139
|
-
description:
|
125
|
+
description:
|
140
126
|
email:
|
141
127
|
- vassilevsky@gmail.com
|
142
128
|
executables:
|
@@ -174,7 +160,7 @@ files:
|
|
174
160
|
homepage: https://github.com/vassilevsky/face_control
|
175
161
|
licenses: []
|
176
162
|
metadata: {}
|
177
|
-
post_install_message:
|
163
|
+
post_install_message:
|
178
164
|
rdoc_options: []
|
179
165
|
require_paths:
|
180
166
|
- lib
|
@@ -189,9 +175,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
175
|
- !ruby/object:Gem::Version
|
190
176
|
version: '0'
|
191
177
|
requirements: []
|
192
|
-
|
193
|
-
|
194
|
-
signing_key:
|
178
|
+
rubygems_version: 3.0.3
|
179
|
+
signing_key:
|
195
180
|
specification_version: 4
|
196
181
|
summary: Checks Atlassian Stash pull requests and comments on issues in added code
|
197
182
|
test_files: []
|