linterbot 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c2e9bd02e15964967d9c7006c8069ece73e5e67
4
- data.tar.gz: 2034fbd20f8876edd421ecca00a001f96ba99a65
3
+ metadata.gz: abcda56ecd4fea3e725995d9de4133e317ed45c4
4
+ data.tar.gz: 1bf1db02125fb034dceffd0ef74f84dbaa5e438c
5
5
  SHA512:
6
- metadata.gz: c776bac236b0e9954ae61411fb3fcff3682dcc208c350a69cf2ac9925efb6de0110136d527fbfe164a777ebb928b451d91be5c319cf136dd3f10f350299b8dd7
7
- data.tar.gz: 502c31793d29772ede43f838cf0673f5059633aa56e9075469a6d25560726db5edcf8aa8b7d2d1fa79ebfecb9cb1296e98e286d419fcc1bd3c8c609e437d678b
6
+ metadata.gz: b2b799eec7600fac75d9a963c88542a156d7155308613d4de492cbca436e910fe89e730b6643463858d9e4ec5eed3ccd2a8d716a73c509fabd8b4776f02eff22
7
+ data.tar.gz: 8a82dd0167db2fba31b3d2affa9cac0546ccda44f0392cec028d0f8900c2c369e59fc16b08d3d52952c40d7d98ca91560b200f74f8a0c419671c8008c46aeff8
data/README.md CHANGED
@@ -42,7 +42,7 @@ If you want to run it in TravisCI for every pull request triggered build you can
42
42
  if [ "$TRAVIS_PULL_REQUEST" != "false" ]
43
43
  then
44
44
  swiftlint --reporter json > switlint-report.json || false
45
- linterbot $TRAVIS_REPO_SLUG $TRAVIS_PULL_REQUEST < swiftlint-report
45
+ linterbot $TRAVIS_REPO_SLUG $TRAVIS_PULL_REQUEST < swiftlint-report.json
46
46
  fi
47
47
  ```
48
48
  *`|| false` avoids a build fail if there are severe lint error*
@@ -75,7 +75,9 @@ linterbot help run
75
75
 
76
76
  ### GitHub access
77
77
 
78
- In order for linterbot to be able to comment on your pull request it needs write access to the specified repository. You can provided an access token by either using the environmental variable `GITHUB_ACCESS_TOKEN` or using the `.linterbot.yml` (which should not be committed to your git repository).
78
+ In order for linterbot to be able to comment on your pull request it needs write access to the specified repository. Remember to add the `repo` scope when you create the GitHub access token. If you don't lintebot won't be able to run. For more information on how to create an access token check [this](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) tutorial. If you want to know more about GitHub's OAuth scopes check [this](https://developer.github.com/v3/oauth/#scopes) section in their documentation.
79
+
80
+ You can provided an access token by either using the environmental variable `GITHUB_ACCESS_TOKEN` or using the `.linterbot.yml` (which should not be committed to your git repository).
79
81
 
80
82
  ### Configuration file
81
83
 
data/exe/linterbot CHANGED
@@ -46,7 +46,15 @@ command :run do |c|
46
46
  puts "Linterbot has successfully reviewed your PR ;-)"
47
47
  rescue Linterbot::RunnerConfiguration::MissingAttribute => exception
48
48
  STDERR.puts "Missing configuration attribute '#{exception.attribute_name}'"
49
- STDERR.puts "#{exception.fix_description}"
49
+ STDERR.puts "#{exception.fix_description}\n"
50
+ exit 1
51
+ rescue Linterbot::RunnerConfiguration::InvalidGitHubCredentials => exception
52
+ STDERR.puts "Invalid GitHub credentials"
53
+ STDERR.puts "The given access token does not have the 'repo' scope"
54
+ STDERR.puts "\nFor more info on how to create an access token check:"
55
+ STDERR.puts "https://help.github.com/articles/creating-an-access-token-for-command-line-use/"
56
+ STDERR.puts "\nIf you want to know more about GitHub's OAuth scopes check:"
57
+ STDERR.puts "https://developer.github.com/v3/oauth/#scopes\n"
50
58
  exit 1
51
59
  end
52
60
  end
@@ -21,6 +21,9 @@ module Linterbot
21
21
 
22
22
  end
23
23
 
24
+ class InvalidGitHubCredentials < Exception
25
+ end
26
+
24
27
  DEFAULT_PROJECT_BASE_PATH = './'
25
28
  DEFAULT_CONFIG_FILE_PATH = './.linterbot.yml'
26
29
 
@@ -70,6 +73,7 @@ module Linterbot
70
73
  github_access_token = ENV["GITHUB_ACCESS_TOKEN"] || base_config[:github_access_token]
71
74
  raise missing_github_access_token unless github_access_token
72
75
  github_client = Octokit::Client.new(access_token: github_access_token)
76
+ validate_github_access!(github_client)
73
77
 
74
78
  configuration = new(github_client, base_config)
75
79
  configuration.project_base_path = options.project_base_path if options.project_base_path
@@ -83,6 +87,14 @@ module Linterbot
83
87
  configuration
84
88
  end
85
89
 
90
+ def validate_github_access!(github_client)
91
+ raise InvalidGitHubCredentials.new unless full_repo_access?(github_client)
92
+ end
93
+
94
+ def full_repo_access?(github_client)
95
+ github_client.scopes.include?("repo")
96
+ end
97
+
86
98
  end
87
99
 
88
100
  def initialize(github_client, options)
@@ -1,3 +1,3 @@
1
1
  module Linterbot
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linterbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guido Marucci Blas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler