github_backup 0.1.3 → 0.1.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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/exe/gist-backup +45 -0
- data/exe/github-backup +15 -43
- data/github_backup.gemspec +8 -4
- data/lib/github_backup/version.rb +1 -1
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e2d661538d990d46a1a974371d1bba45dce2e8c97c8b07af489a8f5237c0dd3
|
4
|
+
data.tar.gz: ed8dfceef3569a44d8da9e99beba58d83740220b3344d38d8b535f9517ad1eea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c635befcd2bb27e3ca0917266e2cfb63961ef7f2114a81a72c7c8e0f62e1be277f02163a937935013ea0306e9f965c74fef79b7974d9e9f8e25a4a066dc9aba7
|
7
|
+
data.tar.gz: bf37fb2d0ce79fe4c8a0d9053eb69727b2b93439389e4971a18294d3344bbefee08171b6f674d483896bb21f4aa94d13a6df079d1d3b6186e280a688de8a20ff
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.6.
|
1
|
+
ruby-2.6.5
|
data/exe/gist-backup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.join(__dir__, '..', 'lib')
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'shellwords'
|
7
|
+
require 'thread'
|
8
|
+
require 'github_backup'
|
9
|
+
require 'github_backup/git'
|
10
|
+
include GithubBackup::Helpers
|
11
|
+
|
12
|
+
config = GithubBackup::Config.new(File.join(__dir__, '..', 'default_config.json'))
|
13
|
+
|
14
|
+
config['repos_path'] ||= File.join(Dir.home, 'Repos')
|
15
|
+
config['backup_path'] ||= File.join(Dir.home, 'Documents', 'RepoBundles')
|
16
|
+
|
17
|
+
if !config['token']
|
18
|
+
puts "Please enter your github token: "
|
19
|
+
config['token'] = gets.chomp
|
20
|
+
end
|
21
|
+
|
22
|
+
config.save
|
23
|
+
github = GithubBackup::Api.new(config['token'])
|
24
|
+
|
25
|
+
# Create the path and move to that location
|
26
|
+
path = File.expand_path(File.join(config['repos_path'], 'gists'))
|
27
|
+
FileUtils.mkdir_p(path)
|
28
|
+
Dir.chdir path
|
29
|
+
|
30
|
+
# Fetch all gists
|
31
|
+
gists = github.get('/gists')
|
32
|
+
while page = github.next
|
33
|
+
gists.concat page
|
34
|
+
end
|
35
|
+
|
36
|
+
gists.each do |gist|
|
37
|
+
unless File.exist? gist['id']
|
38
|
+
puts `git clone #{gist['git_pull_url']}`
|
39
|
+
else
|
40
|
+
inside gist['id'] do
|
41
|
+
puts "Gist: #{gist['id']}"
|
42
|
+
puts `git pull`
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/exe/github-backup
CHANGED
@@ -22,28 +22,6 @@ end
|
|
22
22
|
config.save
|
23
23
|
github = GithubBackup::Api.new(config['token'])
|
24
24
|
|
25
|
-
# # ===============
|
26
|
-
# # = Clone gists =
|
27
|
-
# # ===============
|
28
|
-
#
|
29
|
-
# inside 'gists' do
|
30
|
-
# gists = github.get('/gists')
|
31
|
-
# while page = github.next
|
32
|
-
# gists.concat page
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# gists.each do |gist|
|
36
|
-
# unless File.exist? gist['id']
|
37
|
-
# puts `git clone #{gist['git_pull_url']}`
|
38
|
-
# else
|
39
|
-
# inside gist['id'] do
|
40
|
-
# puts "Gist: #{gist['id']}"
|
41
|
-
# puts `git pull`
|
42
|
-
# end
|
43
|
-
# end
|
44
|
-
# end
|
45
|
-
# end
|
46
|
-
|
47
25
|
puts "Fetching repos..."
|
48
26
|
page_no = 0
|
49
27
|
puts "page #{page_no += 1}"
|
@@ -56,34 +34,28 @@ puts "Done!"
|
|
56
34
|
|
57
35
|
clone_urls = repos.map { |repo| repo['ssh_url'] }
|
58
36
|
|
59
|
-
@threads = []
|
60
|
-
|
61
37
|
clone_urls.each do |url|
|
62
38
|
user = /github\.com.([^\/]+)/.match(url)[1]
|
63
39
|
project_name = File.basename(url.split('/').last, '.git')
|
64
40
|
path = File.expand_path(File.join(config['repos_path'], user, project_name))
|
65
41
|
FileUtils.mkdir_p(File.dirname(path))
|
42
|
+
Dir.chdir(File.dirname(path))
|
66
43
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
cmd = "git clone #{url} #{Shellwords.shellescape(path)}"
|
72
|
-
puts cmd
|
73
|
-
puts `#{cmd}`
|
44
|
+
unless File.exist?(path)
|
45
|
+
cmd = "git clone #{url} #{Shellwords.shellescape(path)}"
|
46
|
+
puts cmd
|
47
|
+
result = `#{cmd}`
|
74
48
|
Dir.chdir(path)
|
75
|
-
|
49
|
+
else
|
76
50
|
Dir.chdir(path)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
backup_path = File.expand_path(File.join(config['backup_path'], user))
|
82
|
-
FileUtils.mkdir_p(backup_path)
|
83
|
-
bundle = "#{project_name}.gitbundle"
|
84
|
-
bundle_path = File.join(backup_path, bundle)
|
85
|
-
puts `git bundle create #{Shellwords.shellescape(bundle_path)} --all --remotes`
|
51
|
+
puts "Updating existing repo: #{path}"
|
52
|
+
git_updater = GithubBackup::Git.new
|
53
|
+
git_updater.update
|
86
54
|
end
|
87
|
-
end
|
88
55
|
|
89
|
-
|
56
|
+
backup_path = File.expand_path(File.join(config['backup_path'], user))
|
57
|
+
FileUtils.mkdir_p(backup_path)
|
58
|
+
bundle = "#{project_name}.gitbundle"
|
59
|
+
bundle_path = File.join(backup_path, bundle)
|
60
|
+
result = `git bundle create #{Shellwords.shellescape(bundle_path)} --all --remotes`
|
61
|
+
end
|
data/github_backup.gemspec
CHANGED
@@ -7,11 +7,15 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "github_backup"
|
8
8
|
spec.version = GithubBackup::VERSION
|
9
9
|
spec.authors = ["Alex Clink"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["hello@alexclink.com"]
|
11
11
|
|
12
12
|
spec.summary = "Create backups of your github repos"
|
13
13
|
spec.description = "Automatically clones your github repos and makes git bundles"
|
14
|
-
spec.homepage = "
|
14
|
+
spec.homepage = "https://github.com/SleepingInsomniac/github-backup"
|
15
|
+
|
16
|
+
spec.metadata = {
|
17
|
+
"source_code_uri" => "https://github.com/SleepingInsomniac/github-backup"
|
18
|
+
}
|
15
19
|
|
16
20
|
# Specify which files should be added to the gem when it is released.
|
17
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -22,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
22
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
27
|
spec.require_paths = ["lib"]
|
24
28
|
|
25
|
-
spec.add_development_dependency "bundler", "~>
|
26
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
27
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
28
32
|
|
29
33
|
spec.add_dependency "link_header"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Clink
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,8 +82,9 @@ dependencies:
|
|
82
82
|
version: '0'
|
83
83
|
description: Automatically clones your github repos and makes git bundles
|
84
84
|
email:
|
85
|
-
-
|
85
|
+
- hello@alexclink.com
|
86
86
|
executables:
|
87
|
+
- gist-backup
|
87
88
|
- github-backup
|
88
89
|
extensions: []
|
89
90
|
extra_rdoc_files: []
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- Rakefile
|
98
99
|
- bin/console
|
99
100
|
- bin/setup
|
101
|
+
- exe/gist-backup
|
100
102
|
- exe/github-backup
|
101
103
|
- github_backup.gemspec
|
102
104
|
- lib/github_backup.rb
|
@@ -106,9 +108,10 @@ files:
|
|
106
108
|
- lib/github_backup/helpers.rb
|
107
109
|
- lib/github_backup/json_store.rb
|
108
110
|
- lib/github_backup/version.rb
|
109
|
-
homepage:
|
111
|
+
homepage: https://github.com/SleepingInsomniac/github-backup
|
110
112
|
licenses: []
|
111
|
-
metadata:
|
113
|
+
metadata:
|
114
|
+
source_code_uri: https://github.com/SleepingInsomniac/github-backup
|
112
115
|
post_install_message:
|
113
116
|
rdoc_options: []
|
114
117
|
require_paths:
|