face_control 0.8.3 → 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/.gitignore +1 -0
- data/.vexor.yml +0 -1
- data/README.md +55 -37
- data/Rakefile +0 -1
- data/face_control.gemspec +1 -2
- data/lib/face_control/checkers/rubocop.rb +3 -11
- data/lib/face_control/cli.rb +1 -10
- data/lib/stash/config.rb +6 -2
- data/lib/stash/pull_request/diff.rb +1 -0
- 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/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,76 +1,94 @@
|
|
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
|
-
|
9
|
+
Run static analysis of pull requests in [Bitbucket Server][] (formerly Stash)
|
10
|
+
and comment on problems in added lines.
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
(Currently supports [RuboCop][] and [CoffeeLint][].)
|
12
|
+
Currently supports [RuboCop][] and [CoffeeLint][] and also checks for
|
13
|
+
TODOs and FIXMEs.
|
12
14
|
|
13
15
|
Inspired by [Hound][].
|
14
16
|
|
15
17
|
## Installation
|
16
18
|
|
17
|
-
|
19
|
+
```bash
|
20
|
+
gem install face_control
|
21
|
+
```
|
22
|
+
|
23
|
+
You also need to have CoffeeLint installed and available in `PATH`.
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
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).
|
32
|
+
|
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
|
+
```
|
22
39
|
|
23
|
-
|
24
|
-
For example, here's a [Jenkins][] project setup:
|
40
|
+
Instead of `--skip-severity` you can use just `-S`.
|
25
41
|
|
26
|
-
|
27
|
-
* Git
|
28
|
-
* Repositories
|
29
|
-
* Refspec:
|
42
|
+
You can also pass multiple severity levels as a comma-separated list:
|
30
43
|
|
31
|
-
|
44
|
+
```bash
|
45
|
+
face-control -S convention,refactor <project> <repository> <pull_request_id>
|
46
|
+
```
|
32
47
|
|
33
|
-
|
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.
|
34
51
|
|
35
|
-
|
36
|
-
* Branch Specifier:
|
52
|
+
## Example
|
37
53
|
|
38
|
-
|
54
|
+
Here's a [Jenkins][] project setup as an example:
|
39
55
|
|
40
|
-
|
56
|
+
_Source Code Management → Git → Repositories → Refspec:_
|
41
57
|
|
42
|
-
|
43
|
-
|
44
|
-
|
58
|
+
```
|
59
|
+
+refs/pull-requests/*:refs/remotes/origin/pull-requests/*
|
60
|
+
```
|
45
61
|
|
46
|
-
|
62
|
+
It makes Jenkins fetch otherwise ignored Stash-created branches.
|
47
63
|
|
48
|
-
|
49
|
-
npm install -g coffeelint
|
64
|
+
_Source Code Management → Git → Branches to build → Branch Specifier:_
|
50
65
|
|
51
|
-
|
66
|
+
```
|
67
|
+
origin/pull-requests/*/merge
|
68
|
+
```
|
52
69
|
|
53
|
-
|
54
|
-
pass the severity in the `--skip-severity` option like so:
|
70
|
+
Merge results of open non-conflicting pull requests.
|
55
71
|
|
56
|
-
|
72
|
+
_Build → Execute shell → Command:_
|
57
73
|
|
58
|
-
|
59
|
-
|
74
|
+
```bash
|
75
|
+
export PULL_REQUEST_ID=`echo $GIT_BRANCH | cut -d / -f 3`
|
60
76
|
|
61
|
-
|
77
|
+
gem install rubocop face_control
|
78
|
+
npm install -g coffeelint
|
62
79
|
|
63
|
-
|
64
|
-
|
65
|
-
to connect to your Stash instance.
|
80
|
+
face-control <project> <repository> $PULL_REQUEST_ID
|
81
|
+
```
|
66
82
|
|
67
83
|
## Etymology
|
68
84
|
|
69
|
-
[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)
|
70
88
|
|
71
89
|
[Hound]: https://houndci.com
|
72
|
-
[
|
73
|
-
[
|
90
|
+
[Bitbucket Server]: https://www.atlassian.com/software/bitbucket/server
|
91
|
+
[Bitbucket Server Command Line Tools]: https://bitbucket.org/atlassian/bitbucket-server-cli
|
74
92
|
[RuboCop]: http://batsov.com/rubocop/
|
75
93
|
[CoffeeLint]: http://www.coffeelint.org
|
76
94
|
[Jenkins]: http://jenkins-ci.org
|
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.
|
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'
|
@@ -52,21 +52,13 @@ module FaceControl
|
|
52
52
|
text << " — [Guide](#{link})"
|
53
53
|
end
|
54
54
|
|
55
|
-
|
56
|
-
text << " (Run `rubocop -a #{file['path']}` to fix.)"
|
57
|
-
end
|
58
|
-
|
59
|
-
text
|
55
|
+
text << " — #{offense['cop_name']}"
|
60
56
|
end
|
61
57
|
|
62
58
|
def style_guide_url(offense)
|
63
59
|
cop_name = offense['cop_name']
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def can_be_autocorrected?(offense)
|
69
|
-
!offense['corrected'].nil?
|
60
|
+
config = ::RuboCop::ConfigLoader.default_configuration
|
61
|
+
::RuboCop::Cop::MessageAnnotator.new(config, cop_name, config.for_cop(cop_name), {}).urls.first
|
70
62
|
end
|
71
63
|
end
|
72
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.
|
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: []
|