upstream 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/bin/upstream +27 -0
- data/lib/upstream.rb +128 -0
- data/lib/upstream/version.rb +3 -0
- data/upstream.gemspec +24 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6bb8d9f45e95380c65b830bf1dd09d6c4a9e858c
|
4
|
+
data.tar.gz: d23955d84fcadc3526fc2e02d8e67f3f272b218a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c82efffcfa9b27a68b73ec474d1fd464b30884e8ce3e70420d207bc958e3f3d240e9bf76af3c0aca3aa33755c18069cd3004e6c19c4d4c043ec48e4439ff197e
|
7
|
+
data.tar.gz: 9a45b25759a6db54388a93f2fe71c1faea04c885d696778918aa59bde28f63ee4bd0d4980c18d0f993b53cebdf41bc6270d6cc718d085d5df6e03dec91fb81f4
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Logan Hasson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Upstream
|
2
|
+
|
3
|
+
Set up cron jobs to automatically fetch from your upstream remotes.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
`$ gem install upstream`
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
You must have a public/private key pair (with no passphrase) called `github_id_rsa` in your `~/.ssh` directory. Create this by running the following command:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ ssh-keygen
|
15
|
+
```
|
16
|
+
|
17
|
+
When prompted, enter `/Users/<yourusername>/.ssh/github_id_rsa`.
|
18
|
+
|
19
|
+
Then, when asked for a passphrase, just press Return twice.
|
20
|
+
|
21
|
+
Finally, `cat /Users/<yourusername>/.ssh/github_id_rsa.pub`, copy the output, and paste it as a new SSH key on GitHub.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ cd <path-to-your-repository>
|
27
|
+
$ upstream .
|
28
|
+
```
|
29
|
+
|
30
|
+
## Options
|
31
|
+
|
32
|
+
Pull instead of just fetch from your upstream remotes.
|
33
|
+
|
34
|
+
```bash
|
35
|
+
$ upstream . -p, --pull
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/[my-github-username]/upstream/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
45
|
+
|
46
|
+
## TODO
|
47
|
+
|
48
|
+
1. Add option to cancel cron job
|
49
|
+
|
50
|
+
Built by [@loganhasson](http://twitter.com/loganhasson) in NYC
|
data/Rakefile
ADDED
data/bin/upstream
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'upstream'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
pull = false
|
7
|
+
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: upstream . [options]"
|
10
|
+
|
11
|
+
opts.on("-p", "--pull", "Automatically pull instead of fetch from upstream") do |p|
|
12
|
+
pull = true
|
13
|
+
end
|
14
|
+
end.parse!
|
15
|
+
|
16
|
+
if !ARGV[0]
|
17
|
+
puts `upstream --help`
|
18
|
+
elsif ARGV[0] != '.' && !ARGV[0].start_with?('/')
|
19
|
+
puts "Please specify an absolute path."
|
20
|
+
else
|
21
|
+
repo_path = Upstream::PathFinder.get_path(ARGV[0])
|
22
|
+
if Upstream::PathChecker.has_upstream?(repo_path)
|
23
|
+
Upstream::Tracker.run(repo_path, pull)
|
24
|
+
else
|
25
|
+
puts "Please add an upstream remote to this repository."
|
26
|
+
end
|
27
|
+
end
|
data/lib/upstream.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require "upstream/version"
|
2
|
+
|
3
|
+
module Upstream
|
4
|
+
|
5
|
+
class Tracker
|
6
|
+
attr_reader :path, :pull
|
7
|
+
|
8
|
+
def initialize(path, pull=false)
|
9
|
+
@path = path
|
10
|
+
@pull = pull
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.run(path, pull)
|
14
|
+
new(path, pull).setup
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
wheneverizer = Wheneverizer.new(path, pull)
|
19
|
+
wheneverizer.run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class PathFinder
|
24
|
+
attr_reader :raw_path
|
25
|
+
|
26
|
+
def initialize(arg)
|
27
|
+
@raw_path = arg
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.get_path(arg)
|
31
|
+
new(arg).parse
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse
|
35
|
+
if raw_path == '.'
|
36
|
+
`pwd`.chomp
|
37
|
+
else
|
38
|
+
raw_path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class PathChecker
|
44
|
+
attr_reader :path
|
45
|
+
|
46
|
+
def initialize(path)
|
47
|
+
@path = path
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.has_upstream?(path)
|
51
|
+
new(path).check
|
52
|
+
end
|
53
|
+
|
54
|
+
def check
|
55
|
+
`cd #{path} && git remote -v`.match(/upstream/) ? true : false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Wheneverizer
|
60
|
+
attr_reader :path, :pull
|
61
|
+
|
62
|
+
def initialize(path, pull=false)
|
63
|
+
@path = path
|
64
|
+
@already_existed = schedule_exists?
|
65
|
+
@pull = pull
|
66
|
+
end
|
67
|
+
|
68
|
+
def run
|
69
|
+
setup
|
70
|
+
write_schedule
|
71
|
+
wheneverize
|
72
|
+
clean_up
|
73
|
+
end
|
74
|
+
|
75
|
+
def setup
|
76
|
+
if !already_existed?
|
77
|
+
if !File.exist?("#{path}/config")
|
78
|
+
`cd #{path} && mkdir config && wheneverize .`
|
79
|
+
else
|
80
|
+
`cd #{path} && wheneverize .`
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def schedule_exists?
|
86
|
+
File.exist?("#{path}/config/schedule.rb")
|
87
|
+
end
|
88
|
+
|
89
|
+
def already_existed?
|
90
|
+
@already_existed
|
91
|
+
end
|
92
|
+
|
93
|
+
def write_schedule
|
94
|
+
if !schedule_exists?
|
95
|
+
write_args = ['config/schedule.rb', 'w+']
|
96
|
+
else
|
97
|
+
write_args = ['config/schedule.rb', 'a']
|
98
|
+
end
|
99
|
+
|
100
|
+
fetch_or_pull = pull ? "pull" : "fetch"
|
101
|
+
|
102
|
+
File.open(*write_args) do |f|
|
103
|
+
f.puts <<-COMMAND.gsub(/^ {10}/, '')
|
104
|
+
every 1.hour do
|
105
|
+
command "eval $(ssh-agent) && ssh-add ~/.ssh/github_id_rsa && cd #{path} && git #{fetch_or_pull} upstream master"
|
106
|
+
end
|
107
|
+
COMMAND
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def wheneverize
|
112
|
+
`whenever --update-crontab`
|
113
|
+
end
|
114
|
+
|
115
|
+
def clean_up
|
116
|
+
file_count = `ls -a config | wc -l`.strip.to_i
|
117
|
+
|
118
|
+
if !already_existed?
|
119
|
+
if file_count > 3
|
120
|
+
`rm config/schedule.rb`
|
121
|
+
else
|
122
|
+
`rm -rf config`
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
data/upstream.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'upstream/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "upstream"
|
8
|
+
spec.version = Upstream::VERSION
|
9
|
+
spec.authors = ["Logan Hasson"]
|
10
|
+
spec.email = ["logan.hasson@gmail.com"]
|
11
|
+
spec.summary = %q{Upstream keeps your fork up to date.}
|
12
|
+
spec.description = %q{Automatically fetch from upstream every hour.}
|
13
|
+
spec.homepage = "http://google.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib", "bin"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
23
|
+
spec.add_runtime_dependency "whenever", "~> 0.9"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: upstream
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Logan Hasson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: whenever
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
description: Automatically fetch from upstream every hour.
|
56
|
+
email:
|
57
|
+
- logan.hasson@gmail.com
|
58
|
+
executables:
|
59
|
+
- upstream
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/upstream
|
69
|
+
- lib/upstream.rb
|
70
|
+
- lib/upstream/version.rb
|
71
|
+
- upstream.gemspec
|
72
|
+
homepage: http://google.com
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
- bin
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Upstream keeps your fork up to date.
|
97
|
+
test_files: []
|