git-grabber 0.0.1 → 0.0.2
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/README.md +36 -2
- data/bin/gitgrabber +1 -1
- data/lib/git_grabber.rb +3 -3
- data/lib/git_grabber/config.rb +10 -6
- data/lib/git_grabber/puller.rb +2 -2
- data/lib/git_grabber/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35e2d2b91c9aa98f3a397984cef79927498327db
|
|
4
|
+
data.tar.gz: 1325bade58dae8a60afa2904ef930f31ee298f5c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 947fa222c6e446af4a4505369ce778bcf5f83b52d935a2bf08c9fc441f94ebcca38c788868d0c950d6b1d027f454cacdd1fb62cc02b9526e507fb86b8282cda5
|
|
7
|
+
data.tar.gz: eae55e29b7d946a0b7e2e60d46061ab95fee651073ddbbdd41f7f174a121046ccc35895277aefe68204896f08323db2b7c28f458e38c352e5795e9c2ccca0f24
|
data/README.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Git Grabber
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A simple github backup tool, for peace of mind.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Add settings to config.json:
|
|
8
|
+
|
|
9
|
+
1. Generate a github personal token
|
|
10
|
+
2. Set an interval (min 60 seconds. Depending on your usage once or twice a day is probably enough, your mileage may vary.)
|
|
11
|
+
3. Set a backup directory where projects should be cloned/fetched.
|
|
12
|
+
|
|
13
|
+
Run the application `gitgrabber` from your command line (you can fork it to the background in bash with `gitgrabber &`) the application will log its progress so redirect to a file or `/dev/null` if you're not interested.
|
|
14
|
+
|
|
15
|
+
For issues, please use the issue tracker on the repository.
|
|
16
|
+
|
|
17
|
+
Pull requests welcome.
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2014 Peter Mellett
|
|
20
|
+
|
|
21
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
22
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
23
|
+
in the Software without restriction, including without limitation the rights
|
|
24
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
25
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
26
|
+
furnished to do so, subject to the following conditions:
|
|
27
|
+
|
|
28
|
+
The above copyright notice and this permission notice shall be included in all
|
|
29
|
+
copies or substantial portions of the Software.
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
32
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
33
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
34
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
35
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
36
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
37
|
+
SOFTWARE.
|
data/bin/gitgrabber
CHANGED
data/lib/git_grabber.rb
CHANGED
|
@@ -6,12 +6,12 @@ require 'git_grabber/puller'
|
|
|
6
6
|
module GitGrabber
|
|
7
7
|
class Application
|
|
8
8
|
def config(path)
|
|
9
|
-
@config =
|
|
10
|
-
@api
|
|
9
|
+
@config = GitGrabber::Config.new File.read path
|
|
10
|
+
@api = GitGrabber::Api.new @config.github_personal_token
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def go
|
|
14
|
-
puller =
|
|
14
|
+
puller = GitGrabber::Puller.new @config.backup_directory
|
|
15
15
|
|
|
16
16
|
while true
|
|
17
17
|
repos = @api.fetch_all
|
data/lib/git_grabber/config.rb
CHANGED
|
@@ -4,17 +4,21 @@ module GitGrabber
|
|
|
4
4
|
class Config
|
|
5
5
|
attr_accessor :interval, :github_personal_token, :backup_directory
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
8
|
-
|
|
7
|
+
def initialize(conf)
|
|
8
|
+
missing = []
|
|
9
|
+
config = JSON.parse(conf)
|
|
10
|
+
|
|
9
11
|
%w{ interval github_personal_token backup_directory }.each do |required|
|
|
10
12
|
if config[required].nil?
|
|
11
|
-
|
|
13
|
+
missing << required
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
raise "missing required options #{missing.join(', ')}" unless missing.empty?
|
|
18
|
+
|
|
19
|
+
@interval = [config["interval"], 60].max # force 60 seconds min interval
|
|
20
|
+
@github_personal_token = config["github_personal_token"]
|
|
21
|
+
@backup_directory = config["backup_directory"]
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
end
|
data/lib/git_grabber/puller.rb
CHANGED
|
@@ -16,13 +16,13 @@ module GitGrabber
|
|
|
16
16
|
def fetch_repository(addr, path)
|
|
17
17
|
puts "fetch #{addr} to #{File.join @base_dir, path}"
|
|
18
18
|
Dir.chdir(File.join @base_dir, path) do
|
|
19
|
-
|
|
19
|
+
`git fetch --all`
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def clone_repository(addr, path)
|
|
24
24
|
puts "clone #{addr} to #{File.join @base_dir, path}"
|
|
25
|
-
|
|
25
|
+
`git clone --bare #{addr} #{File.join @base_dir, path}`
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
end
|
data/lib/git_grabber/version.rb
CHANGED