github-tv 0.3 → 0.4

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -1
  3. data/bin/github-tv +35 -7
  4. data/github-tv.gemspec +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 394f431dfda18daf4d28a8029df24597a89ebc4d
4
- data.tar.gz: 14805bcf47d60819849d5badf5636354983351db
3
+ metadata.gz: 327ec5b7370f80ce65cdd1e4773ae61ad3218c5d
4
+ data.tar.gz: efa2e8f9e11dbc5c04f3563153541abcfa9eb37a
5
5
  SHA512:
6
- metadata.gz: 0b258ca144cbe17b1e46fec1ee22fa7a2f64a9a71ca1c420b918f6be1ff3839c5bc4d1e5f6b7f298b0cdf2aceb850f50c385e8231914c2c705dcc50563104e7a
7
- data.tar.gz: 038227509055ee627dc807d168f14ca7eb70103b4720d4e5f2c299ca3e3af6897cc0b04182810c83300cbdc90591d7eae783e123080ca1e284fcf58d32a13d1e
6
+ metadata.gz: 63f4c41fc5f3f5e0ffc5025741b6d009f87c94c3ecb33db4b3bb73033a647c50a777749b4cc709d2fab86bf930843935bb6aff80f7b7bdc07fdc59baeaddb645
7
+ data.tar.gz: 436a344a4559f89361456acecabc685fe654311de9c4e7424106966e5d23ae4b376146a34a014d4dfbfdb0d447fbf8880afd564f1b112c678b0fdc220b4479a9
data/README.md CHANGED
@@ -19,9 +19,15 @@ repos:
19
19
  - user2/repo2
20
20
  ```
21
21
 
22
+ Optionally, you can set default path/url to config file.
23
+
24
+ ```bash
25
+ git config --global github.tv.config *path/url for config*
26
+ ```
27
+
22
28
  ## Contributors
23
29
 
24
- * @gazay, @brainopia
30
+ * @gazay, @brainopia, @igas, @aderyabin
25
31
 
26
32
  ## License
27
33
 
data/bin/github-tv CHANGED
@@ -4,10 +4,34 @@ require_relative '../lib/github-tv'
4
4
  require 'io/console'
5
5
  require 'open-uri'
6
6
 
7
- config_location = ARGV.shift or abort 'Missing path/url for config'
8
- config = YAML.load open config_location
7
+ def create_token(client, tfa=nil)
8
+ opts = {
9
+ scopes: ['public_repo'],
10
+ note: "github-tv #{Time.now}",
11
+ note_url: 'https://github.com/evilmartians/github-tv'
12
+ }
13
+ opts.merge!(headers: { 'X-GitHub-OTP' => tfa }) if tfa
14
+ client.create_authorization opts
15
+ end
16
+
17
+
18
+
19
+
20
+ config_location = ARGV.shift
21
+ config_location ||= `git config github.tv.config`.chomp
9
22
 
10
- token = `git config github.tv`.chomp
23
+ abort 'Missing path/url for config file' if config_location.empty?
24
+
25
+ begin
26
+ config = YAML.load open config_location
27
+ rescue Errno::ENOENT
28
+ abort 'Incorrect path to config file'
29
+ rescue Psych::SyntaxError
30
+ abort 'Config file format is not YAML'
31
+ end
32
+
33
+
34
+ token = `git config github.tv.token`.chomp
11
35
 
12
36
  if token.empty?
13
37
  puts 'Please authenticate yourself to create a token for further usage.'
@@ -23,12 +47,16 @@ if token.empty?
23
47
  login: username,
24
48
  password: password
25
49
 
26
- response = client.create_authorization \
27
- scopes: ['public_repo'],
28
- note: "github-tv #{Time.now}"
50
+ response = begin
51
+ create_token(client)
52
+ rescue Octokit::OneTimePasswordRequired
53
+ print 'Two-factor authentication code: '
54
+ tfa = gets.chomp
55
+ create_token(client, tfa)
56
+ end
29
57
 
30
58
  token = response.token
31
- `git config --global github.tv #{token}`
59
+ `git config --global github.tv.token #{token}`
32
60
  end
33
61
 
34
62
  config['token'] = token
data/github-tv.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'github-tv'
3
- gem.version = '0.3'
3
+ gem.version = '0.4'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = ['brainopia', 'gazay']
6
6
  gem.email = 'brainopia@evilmartians.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-tv
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - brainopia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-11 00:00:00.000000000 Z
12
+ date: 2014-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: octokit