travis-cli-gh 0.0.2.travis.1.2 → 0.0.2.travis.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +1 -0
- data/README.md +16 -2
- data/lib/travis/cli/gh.rb +3 -0
- data/lib/travis/cli/gh/cat.rb +26 -0
- data/lib/travis/cli/gh/fetch.rb +19 -0
- data/lib/travis/cli/gh/github.rb +20 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OGMzOTJhN2NiOTNmZTdjYjExNGE3NTFiMWY5NTQ0NTcxZDZkZTk2Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTgyYzlmYzM1OTc1MGM4Nzk5NGFjMmZlNWUxMDkyMmM3MTE5ZjJjZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2VjZGEyN2Y0Y2YzYjEyNDA5NmM5M2RiMGUzZmQwZDkyMDY4MDk4ZWRkYzQ4
|
10
|
+
MmFkMjM1YTQ1ZDc0MmZhNjRiY2U2ODZmNTM2YzZjYmVlMzBlZTIxY2MxN2Ix
|
11
|
+
ZDY5YjY0OGJiMTM4Y2I4ZTZiMzZiYWU3ZDUyNjY0YTk5ZWZkZDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGU5YzA3ZDNmMWU3YjExNjYzZTQwODdlMGU3OGRkN2ZkMmRhNDgzMWVlYjhh
|
14
|
+
NDBhMzU0OTEyZmUyMGM1YWJmOWQyYmExN2UzZmYzYjg1NTQzZDFlNzczODIx
|
15
|
+
MjhjOWNjY2ExYTg1ZmMzMDE4MDU1NmMwM2YzNzBlMzI4ZTE5Y2Q=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,24 @@
|
|
1
|
-
# GitHub Plugin for Travis CLI
|
1
|
+
# GitHub Plugin for Travis CLI [![Build Status](https://travis-ci.org/travis-ci/travis-cli-gh.png?branch=master)](https://travis-ci.org/travis-ci/travis-cli-gh)
|
2
2
|
|
3
3
|
This plugin for the [Travis Command Line Client](https://github.com/travis-ci/travis#readme) adds commands that interact with the [GitHub API](http://developer.github.com/v3/) rather than the Travis API. This plugin requires Ruby 2.0 or newer.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
-
This plugin adds the following commands: [`gh-login`](#gh-login)
|
7
|
+
This plugin adds the following commands: [`gh-cat`](#gh-cat), [`gh-fetch`](#gh-fetch), [`gh-login`](#gh-login), [`gh-signature`](#gh-signature) and [`gh-whoami`](#gh-whoami). All these commands will use the Travis API endpoint for automatically figuring out which GitHub API endpoint to use (relevant for setups using GitHub Enterprise).
|
8
|
+
|
9
|
+
### `gh-cat`
|
10
|
+
|
11
|
+
This displays one (or more) files from a repository:
|
12
|
+
|
13
|
+
$ travis gh-cat .travis.yml -r rails/rails
|
14
|
+
script: 'ci/travis.rb'
|
15
|
+
before_install:
|
16
|
+
- travis_retry gem install bundler
|
17
|
+
- "rvm current | grep 'jruby' && export AR_JDBC=true || echo"
|
18
|
+
|
19
|
+
### `gh-fetch`
|
20
|
+
|
21
|
+
Just like `travis gh-cat`, but stores the contents in a file by the same name instead of displaying it. Allows you to specify a path to store it under via `-p` and overrides existing files with `-f`.
|
8
22
|
|
9
23
|
### `gh-login`
|
10
24
|
|
data/lib/travis/cli/gh.rb
CHANGED
@@ -4,12 +4,15 @@ require 'fileutils'
|
|
4
4
|
module Travis
|
5
5
|
module CLI
|
6
6
|
module Gh
|
7
|
+
autoload :Cat, 'travis/cli/gh/cat'
|
8
|
+
autoload :Fetch, 'travis/cli/gh/fetch'
|
7
9
|
autoload :GitHub, 'travis/cli/gh/github'
|
8
10
|
autoload :Login, 'travis/cli/gh/login'
|
9
11
|
autoload :Signature, 'travis/cli/gh/signature'
|
10
12
|
autoload :Subcommands, 'travis/cli/gh/subcommands'
|
11
13
|
autoload :VERSION, 'travis/cli/gh/version'
|
12
14
|
autoload :Whoami, 'travis/cli/gh/whoami'
|
15
|
+
#autoload :Write, 'travis/cli/gh/write'
|
13
16
|
|
14
17
|
extend self
|
15
18
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "base64"
|
2
|
+
|
3
|
+
module Travis::CLI
|
4
|
+
module Gh
|
5
|
+
class Cat < RepoCommand
|
6
|
+
include GitHub::AutoAuth, GitHub::Error
|
7
|
+
|
8
|
+
description "displays the contents of a file on GitHub"
|
9
|
+
on '-b', '--ref REF', 'ref to look up the file (defaults to default branch)'
|
10
|
+
|
11
|
+
def run(*paths)
|
12
|
+
paths.each do |path|
|
13
|
+
say fetch(path)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch(path)
|
18
|
+
path = "repos/#{repository.slug}/contents/#{path}"
|
19
|
+
path << "?ref=#{ref}" if ref
|
20
|
+
Base64.decode64(gh[path]['content'])
|
21
|
+
rescue GH::Error => e
|
22
|
+
gh_error(e)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Travis::CLI
|
2
|
+
module Gh
|
3
|
+
class Fetch < Cat
|
4
|
+
description "download a file from a repository"
|
5
|
+
on '-p', '--prefix DIR', 'Prefix to store it under'
|
6
|
+
on '-f', '--force', 'override existing files'
|
7
|
+
|
8
|
+
def run(*paths)
|
9
|
+
error "no such directory #{prefix}" unless prefix.nil? or File.directory? prefix
|
10
|
+
paths.each do |path|
|
11
|
+
target = File.expand_path(path, prefix || Dir.pwd)
|
12
|
+
error "#{path} already exists, use -f to override" if !force and File.exist?(target)
|
13
|
+
say "storing contents of #{color(path, :bold)} as #{color(target, :bold)}"
|
14
|
+
File.write(target, fetch(path))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/travis/cli/gh/github.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
1
|
require 'travis/tools/github'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Travis::CLI
|
4
5
|
module Gh
|
5
6
|
module GitHub
|
7
|
+
module Error
|
8
|
+
def gh_error(e)
|
9
|
+
raise e unless e.respond_to? :info
|
10
|
+
message = e.info[:response_body].to_s
|
11
|
+
message = JSON.load(message).fetch('message') rescue nil
|
12
|
+
error message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
module Anonymous
|
7
17
|
def gh
|
18
|
+
load_gh
|
8
19
|
GH
|
9
20
|
end
|
10
21
|
end
|
@@ -18,6 +29,7 @@ module Travis::CLI
|
|
18
29
|
end
|
19
30
|
|
20
31
|
def auth
|
32
|
+
load_gh
|
21
33
|
@auth ||= Travis::Tools::Github.new(session.config['github']) do |g|
|
22
34
|
g.note = "token for travis-cli-gh"
|
23
35
|
g.scopes = ['user', 'user:email', 'repo']
|
@@ -42,6 +54,14 @@ module Travis::CLI
|
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
57
|
+
module AutoAuth
|
58
|
+
include Authenticated
|
59
|
+
def gh
|
60
|
+
load_gh
|
61
|
+
org? ? GH : super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
45
65
|
module Hooks
|
46
66
|
def hooks
|
47
67
|
@hooks ||= gh["/repos/#{repository.slug}/hooks"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis-cli-gh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.travis.1
|
4
|
+
version: 0.0.2.travis.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
@@ -80,6 +80,8 @@ files:
|
|
80
80
|
- README.md
|
81
81
|
- init.rb
|
82
82
|
- lib/travis/cli/gh.rb
|
83
|
+
- lib/travis/cli/gh/cat.rb
|
84
|
+
- lib/travis/cli/gh/fetch.rb
|
83
85
|
- lib/travis/cli/gh/github.rb
|
84
86
|
- lib/travis/cli/gh/login.rb
|
85
87
|
- lib/travis/cli/gh/signature.rb
|