github-backup 0.5.0 → 0.6.0
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/bin/github-backup +0 -5
- metadata +39 -63
- data/README.md +0 -39
- data/lib/github-backup.rb +0 -102
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 6f820bf92ef5eebcabd487c13e9c74c609ebd2c2
|
4
|
+
data.tar.gz: 1b0f0a15172d22bb5705819f41cd836354944623
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da5ce6808118fa2b2839c4addab2bd2a0d47ea9e07813f832bf55f9f405b6631c50e7466981ebe54d790346f96a20b97906616f06497027d18054b254a609d34
|
7
|
+
data.tar.gz: 765971e2a3c11202fd951edc858f87f71b99870ec39bfa515c4921c1d81e3c5753f01cd3e06963d18dca9e8b1faf5217bf58ba0d75cf7a74da93dd8b535d168a
|
data/bin/github-backup
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
4
|
|
5
|
-
require 'octopi'
|
6
5
|
require 'github-backup'
|
7
6
|
require 'optparse'
|
8
7
|
|
@@ -13,10 +12,6 @@ optionparser = OptionParser.new do |opts|
|
|
13
12
|
opts.on("-t", "--token TOKEN", "Github API Token") do |t|
|
14
13
|
options[:token] = t
|
15
14
|
end
|
16
|
-
|
17
|
-
opts.on("-u", "--username USER", "Github API Username") do |u|
|
18
|
-
options[:login] = u
|
19
|
-
end
|
20
15
|
end
|
21
16
|
optionparser.parse!
|
22
17
|
|
metadata
CHANGED
@@ -1,83 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-backup
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.5.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
9
|
-
David Dollar
|
10
|
-
|
6
|
+
authors:
|
7
|
+
- David Dollar
|
11
8
|
autorequire:
|
12
9
|
bindir: bin
|
13
10
|
cert_chain: []
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
-
none: false
|
22
|
-
requirements:
|
23
|
-
- - ">="
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: "0"
|
26
|
-
type: :development
|
27
|
-
prerelease: false
|
28
|
-
version_requirements: *id001
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: octopi
|
31
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
-
none: false
|
33
|
-
requirements:
|
11
|
+
date: 2015-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
34
17
|
- - ~>
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version:
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
37
20
|
type: :runtime
|
38
21
|
prerelease: false
|
39
|
-
version_requirements:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.7'
|
27
|
+
description:
|
28
|
+
email: david@dollar.io
|
29
|
+
executables:
|
45
30
|
- github-backup
|
46
31
|
extensions: []
|
47
|
-
|
48
32
|
extra_rdoc_files: []
|
49
|
-
|
50
|
-
files:
|
33
|
+
files:
|
51
34
|
- bin/github-backup
|
52
|
-
- README.md
|
53
|
-
- lib/github-backup.rb
|
54
|
-
has_rdoc: true
|
55
35
|
homepage: http://github.com/ddollar/github-backup
|
56
|
-
licenses:
|
57
|
-
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata: {}
|
58
39
|
post_install_message:
|
59
40
|
rdoc_options: []
|
60
|
-
|
61
|
-
require_paths:
|
41
|
+
require_paths:
|
62
42
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: "0"
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
75
53
|
requirements: []
|
76
|
-
|
77
|
-
|
78
|
-
rubygems_version: 1.6.2
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.2.2
|
79
56
|
signing_key:
|
80
|
-
specification_version:
|
57
|
+
specification_version: 4
|
81
58
|
summary: Backup your Github repositories
|
82
59
|
test_files: []
|
83
|
-
|
data/README.md
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# github-backup
|
2
|
-
|
3
|
-
Back up your Github repositories locally.
|
4
|
-
|
5
|
-
To install it as a Gem, just run:
|
6
|
-
|
7
|
-
$ gem install github-backup
|
8
|
-
|
9
|
-
To use it:
|
10
|
-
|
11
|
-
$ github-backup ddollar /path/to/my/backup/root
|
12
|
-
|
13
|
-
## Authenticated Usage
|
14
|
-
|
15
|
-
### Seamless authentication using .gitconfig defaults
|
16
|
-
|
17
|
-
You will need a `~/.gitconfig` file in place with a `[github]` section
|
18
|
-
|
19
|
-
See: http://github.com/guides/tell-git-your-user-name-and-email-address
|
20
|
-
|
21
|
-
### Specify authentication at the command line
|
22
|
-
|
23
|
-
If you don't have a `[github]` section set up in your `~/.gitconfig` file, you
|
24
|
-
can provide your user name and Github API at the command line.
|
25
|
-
|
26
|
-
## License
|
27
|
-
|
28
|
-
MIT License
|
29
|
-
|
30
|
-
## Author
|
31
|
-
|
32
|
-
Created by David Dollar
|
33
|
-
|
34
|
-
Patches contributed by:
|
35
|
-
Gabriel Gilder
|
36
|
-
|
37
|
-
## Copyright
|
38
|
-
|
39
|
-
Copyright (c) 2010 David Dollar.
|
data/lib/github-backup.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'octopi'
|
2
|
-
require 'pp'
|
3
|
-
|
4
|
-
module Github; end
|
5
|
-
|
6
|
-
class Github::Backup
|
7
|
-
|
8
|
-
VERSION = "0.5.0"
|
9
|
-
|
10
|
-
include Octopi
|
11
|
-
|
12
|
-
attr_reader :backup_root, :debug, :username
|
13
|
-
|
14
|
-
def initialize(username, backup_root, options = {})
|
15
|
-
@username = username
|
16
|
-
@backup_root = backup_root
|
17
|
-
@options = options
|
18
|
-
if (options[:token] && !options[:login])
|
19
|
-
options[:login] = @username
|
20
|
-
end
|
21
|
-
@debug = false
|
22
|
-
end
|
23
|
-
|
24
|
-
def execute
|
25
|
-
backup_all @options
|
26
|
-
|
27
|
-
rescue Errno::ENOENT
|
28
|
-
puts "Please install git and create a ~/.gitconfig"
|
29
|
-
puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address"
|
30
|
-
rescue NoMethodError
|
31
|
-
puts "Please add a [github] section to your ~/.gitconfig"
|
32
|
-
puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address"
|
33
|
-
rescue Octopi::APIError => e
|
34
|
-
# only handle "Authentication required" errors
|
35
|
-
unless (e.message =~ /status 401$/)
|
36
|
-
raise e
|
37
|
-
end
|
38
|
-
puts "Github API authentication failed."
|
39
|
-
puts "Please add a [github] section to your ~/.gitconfig"
|
40
|
-
puts " See: http://github.com/guides/tell-git-your-user-name-and-email-address"
|
41
|
-
puts "Or, use the arguments to authenticate with your username and API token."
|
42
|
-
end
|
43
|
-
|
44
|
-
private ######################################################################
|
45
|
-
|
46
|
-
def github_authenticate(options={})
|
47
|
-
if (options[:login])
|
48
|
-
authenticated_with(options) do
|
49
|
-
yield
|
50
|
-
end
|
51
|
-
else
|
52
|
-
authenticated do
|
53
|
-
yield
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def backup_directory_for(repository)
|
59
|
-
File.join(backup_root, repository.name)
|
60
|
-
end
|
61
|
-
|
62
|
-
def backup_all(options={})
|
63
|
-
FileUtils::mkdir_p(backup_root)
|
64
|
-
github_authenticate(options) do
|
65
|
-
repositories = User.find(username).repositories.sort_by { |r| r.name }
|
66
|
-
repositories.each do |repository|
|
67
|
-
puts "Backing up: #{repository.name}"
|
68
|
-
backup_repository repository
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def backup_repository(repository)
|
74
|
-
if File.exists?(backup_directory_for(repository))
|
75
|
-
backup_repository_incremental(repository)
|
76
|
-
else
|
77
|
-
backup_repository_initial(repository)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def backup_repository_initial(repository)
|
82
|
-
FileUtils::cd(backup_root) do
|
83
|
-
shell("git clone -n #{repository.clone_url}")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def backup_repository_incremental(repository)
|
88
|
-
FileUtils::cd(backup_directory_for(repository)) do
|
89
|
-
shell("git remote update")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def shell(command)
|
94
|
-
puts "EXECUTING: #{command}" if debug
|
95
|
-
IO.popen(command, 'r') do |io|
|
96
|
-
output = io.read
|
97
|
-
puts "OUTPUT:" if debug
|
98
|
-
puts output if debug
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|