pulley 0.0.1
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.
- data/README.md +26 -0
- data/bin/pulley +12 -0
- data/lib/pulley.rb +72 -0
- data/pulley.gemspec +23 -0
- metadata +65 -0
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
`pulley` lets you work with github pull requests on the comamnd line.
|
2
|
+
|
3
|
+
# Concept
|
4
|
+
Use shell pipelines to pull data out of pull requests and to update the
|
5
|
+
request with relevant information.
|
6
|
+
|
7
|
+
# Example usage
|
8
|
+
`pulley | add-link-to-staging | pulley --publish`
|
9
|
+
|
10
|
+
# Configuration
|
11
|
+
`pulley` can read its credentials through `git config
|
12
|
+
github.{username|password|repository}`, a file named `config/pulley.yml` under
|
13
|
+
the current directory, or the file `~/.pulley.yml` in the current user's home
|
14
|
+
directory.
|
15
|
+
|
16
|
+
An example ~/.pulley.yml:
|
17
|
+
---
|
18
|
+
:username: xtoddx
|
19
|
+
:password: topsecret
|
20
|
+
:repository: xtoddx/pulley
|
21
|
+
|
22
|
+
# Writing a script for the pipeline
|
23
|
+
Your pipeline script should always read json from stdin and print json to
|
24
|
+
stdout. You can change the contents of `body` or `title` if you add
|
25
|
+
`modifed: true` to the printed json hash (which lets --publish know to update
|
26
|
+
that pull request).
|
data/bin/pulley
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pulley'
|
4
|
+
|
5
|
+
credentials = Pulley::Credentials.load
|
6
|
+
if credentials.empty?
|
7
|
+
abort "Set your credentials. See README at https://github.com/xtoddx/pulley"
|
8
|
+
end
|
9
|
+
|
10
|
+
client = Pulley::Github.new(credentials[:username], credentials[:password],
|
11
|
+
credentials[:repository])
|
12
|
+
Pulley::CLI.display_pull_requests(client.pull_requests)
|
data/lib/pulley.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
require 'octokit'
|
4
|
+
|
5
|
+
module Pulley
|
6
|
+
class Credentials
|
7
|
+
# Find credentials in current repo or global config
|
8
|
+
def self.load
|
9
|
+
load_from_repo || load_from_local_config || load_from_user_config || {}
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def self.load_from_repo
|
15
|
+
user = `git config github.username`.strip
|
16
|
+
password = `git config github.password`.strip
|
17
|
+
repo = `git config github.repository`.strip
|
18
|
+
if !user.empty? and !password.empty? and !repo.empty?
|
19
|
+
{username: user, password: password, repository: repo}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.load_from_local_config
|
24
|
+
read_from_file('config/pulley.yml')
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.load_from_user_config
|
28
|
+
read_from_file(File.expand_path('~/.pulley.yml'))
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.read_from_file filename
|
32
|
+
if File.exist?(filename)
|
33
|
+
YAML.load(File.read(filename))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Github
|
39
|
+
def initialize username, password, repo
|
40
|
+
@repo = repo
|
41
|
+
@connection = Octokit::Client.new(login: username, password: password,
|
42
|
+
auto_traversal: true)
|
43
|
+
end
|
44
|
+
|
45
|
+
def pull_requests
|
46
|
+
@connection.pull_requests(@repo)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class CLI
|
51
|
+
def self.display_pull_requests reqs
|
52
|
+
decorated_reqs = reqs.map{|r| decorate_pull_request(r) }
|
53
|
+
puts decorated_reqs.to_json
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def self.decorate_pull_request req
|
59
|
+
relevant_fields(req)
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.relevant_fields req
|
63
|
+
{number: req[:number],
|
64
|
+
title: req[:title],
|
65
|
+
body: req[:body],
|
66
|
+
branch: req[:head][:label],
|
67
|
+
author: req[:head][:user] ? req[:head][:user][:login] : nil,
|
68
|
+
user: req[:user][:login]}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/pulley.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'pulley'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2012-12-11'
|
5
|
+
|
6
|
+
s.summary = 'A CLI tool for working with Github Pull Requests'
|
7
|
+
s.description = 'Pulley will turn pull requests into a json stream on STDOUT for piping through other programs, it can be piped back in with the --update flag to persist changes to github.'
|
8
|
+
|
9
|
+
s.authors = ['Todd Willey (xtoddx)']
|
10
|
+
s.email = 'xtoddx@gmail.com'
|
11
|
+
s.homepage = 'http://github.com/xtoddx/pulley'
|
12
|
+
|
13
|
+
s.require_paths = %w[lib]
|
14
|
+
s.executables = %w[pulley]
|
15
|
+
|
16
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
17
|
+
s.extra_rdoc_files = %w[README.md]
|
18
|
+
|
19
|
+
s.add_dependency('octokit', '~> 1.19.0')
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pulley
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Todd Willey (xtoddx)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: octokit
|
16
|
+
requirement: &70158929321820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.19.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70158929321820
|
25
|
+
description: Pulley will turn pull requests into a json stream on STDOUT for piping
|
26
|
+
through other programs, it can be piped back in with the --update flag to persist
|
27
|
+
changes to github.
|
28
|
+
email: xtoddx@gmail.com
|
29
|
+
executables:
|
30
|
+
- pulley
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.md
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- bin/pulley
|
37
|
+
- lib/pulley.rb
|
38
|
+
- pulley.gemspec
|
39
|
+
homepage: http://github.com/xtoddx/pulley
|
40
|
+
licenses: []
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.17
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: A CLI tool for working with Github Pull Requests
|
64
|
+
test_files: []
|
65
|
+
has_rdoc:
|