git-confident 0.0.7 → 0.0.8
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.rdoc +1 -0
- data/bin/git-confident +42 -7
- data/lib/git/confident.rb +35 -12
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -69,6 +69,7 @@ an entire folder to backup. You can track a whole folder using a .gcrecusrive fi
|
|
69
69
|
= Alternatives
|
70
70
|
|
71
71
|
* rsync
|
72
|
+
* http://eigenclass.org/hiki/gibak-0.3.0
|
72
73
|
* gitback[http://github.com/brycethornton/gitback] - very similar to this project, but sets up the repository from a config file.
|
73
74
|
* Desktop backup systems
|
74
75
|
* Time machine (on OS X)
|
data/bin/git-confident
CHANGED
@@ -8,28 +8,63 @@ $:.unshift( LIB_PATH )
|
|
8
8
|
require 'git/confident'
|
9
9
|
|
10
10
|
options = {
|
11
|
-
:action => :backup,
|
12
11
|
:path => File.expand_path( Dir::pwd ) # Default to current directory
|
13
12
|
}
|
14
13
|
|
15
|
-
|
16
|
-
opts.
|
14
|
+
def usage
|
15
|
+
puts @opts.to_s
|
16
|
+
exit 0
|
17
|
+
end
|
18
|
+
|
19
|
+
@opts = OptionParser.new do | opts |
|
20
|
+
opts.banner = "Usage: #{ $0 } [options] [FILES]"
|
21
|
+
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Actions:"
|
24
|
+
|
25
|
+
opts.on("-b", "--backup", "Copy tracked files to the repository, commit changes and push") do
|
26
|
+
options[ :action ] = :backup
|
27
|
+
end
|
17
28
|
|
18
29
|
opts.on("-C", "--no-commit", "Only copy files, do not do a git commit") do
|
30
|
+
options[ :action ] = :backup
|
19
31
|
options[ :no_commit ] = true
|
20
32
|
end
|
21
33
|
|
34
|
+
opts.on("-d", "--diff", "Show differences between file system and repository") do
|
35
|
+
options[ :action ] = :diff
|
36
|
+
end
|
37
|
+
|
22
38
|
opts.on("-l", "--list", "List all files in the repository") do
|
23
39
|
options[ :action ] = :list
|
24
40
|
end
|
25
41
|
|
42
|
+
opts.on("-r", "--restore", "Restore system files from the repository") do
|
43
|
+
options[ :action ] = :restore
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on("-h", "--help", "Show usage") do
|
47
|
+
usage
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.separator ""
|
51
|
+
opts.separator "Other options:"
|
52
|
+
|
26
53
|
opts.on("-p", "--path PATH", "The path to the local copy of the repository. Defaults to current directory") do | path |
|
27
54
|
options[ :path ] = File.expand_path( path )
|
28
55
|
end
|
29
56
|
|
30
|
-
opts.
|
31
|
-
|
32
|
-
|
33
|
-
|
57
|
+
opts.separator ""
|
58
|
+
opts.separator "FILES:"
|
59
|
+
opts.separator "Files are given with their repository path."
|
60
|
+
opts.separator "E.g. a file that resides in /home/user/my_file"
|
61
|
+
opts.separator " has a repository path of home/user/my_file"
|
62
|
+
end
|
63
|
+
|
64
|
+
@opts.parse!
|
65
|
+
|
66
|
+
usage if options[ :action ].nil?
|
67
|
+
|
68
|
+
options[ :files ] = ARGV.clone if ARGV.size > 0
|
34
69
|
|
35
70
|
Git::Confident.new( options )
|
data/lib/git/confident.rb
CHANGED
@@ -9,8 +9,8 @@ module Git
|
|
9
9
|
module VERSION #:nodoc:
|
10
10
|
MAJOR = 0
|
11
11
|
MINOR = 0
|
12
|
-
TINY =
|
13
|
-
|
12
|
+
TINY = 8
|
13
|
+
|
14
14
|
STRING = [ MAJOR, MINOR, TINY ].join( '.' )
|
15
15
|
end
|
16
16
|
|
@@ -18,6 +18,7 @@ module Git
|
|
18
18
|
|
19
19
|
def initialize( options )
|
20
20
|
@path = options[ :path ].clone
|
21
|
+
@files = options[ :files ]
|
21
22
|
@no_commit = options[ :no_commit ] ? true : false
|
22
23
|
|
23
24
|
raise "Git repository not found at '#{ @path }'" if ! File.directory?( "#{ @path }/.git" )
|
@@ -28,20 +29,25 @@ module Git
|
|
28
29
|
case options[ :action ]
|
29
30
|
when :backup
|
30
31
|
backup
|
32
|
+
when :diff
|
33
|
+
diff
|
31
34
|
when :list
|
32
|
-
|
33
|
-
puts @elements.files
|
34
|
-
puts "Folders:"
|
35
|
-
puts @elements.folders
|
36
|
-
puts "Ignored:"
|
37
|
-
puts @elements.ignored
|
35
|
+
list
|
38
36
|
when :restore
|
39
37
|
restore
|
40
|
-
end
|
38
|
+
end
|
41
39
|
end
|
42
40
|
|
43
41
|
private
|
44
42
|
|
43
|
+
def file_list
|
44
|
+
if @files
|
45
|
+
@files
|
46
|
+
else
|
47
|
+
@elements.files + @elements.folders
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
45
51
|
def backup
|
46
52
|
local_backup
|
47
53
|
return if @no_commit
|
@@ -49,15 +55,32 @@ module Git
|
|
49
55
|
push
|
50
56
|
end
|
51
57
|
|
58
|
+
def diff
|
59
|
+
file_list.each do | pathname |
|
60
|
+
s = `diff -U 2 #{ @path }/#{ pathname } /#{ pathname }`
|
61
|
+
puts s unless s.empty?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def list
|
66
|
+
@elements = Git::Elements.new( @path )
|
67
|
+
puts "Files:"
|
68
|
+
puts @elements.files
|
69
|
+
puts "Folders:"
|
70
|
+
puts @elements.folders
|
71
|
+
puts "Ignored:"
|
72
|
+
puts @elements.ignored
|
73
|
+
end
|
74
|
+
|
52
75
|
def restore
|
53
76
|
IO.popen( "rsync --no-perms --executability --keep-dirlinks --delete --files-from=- #{ @path }/ /", "w+" ) do | pipe |
|
54
|
-
|
77
|
+
file_list.each { | pathname | pipe.puts pathname }
|
55
78
|
end
|
56
79
|
end
|
57
80
|
|
58
81
|
def local_backup
|
59
|
-
IO.popen( "rsync -a --recursive --delete --files-from=- / #{ @path }/", "w+" ) do | pipe |
|
60
|
-
|
82
|
+
IO.popen( "rsync -a --recursive --copy-dirlinks --delete --files-from=- / #{ @path }/", "w+" ) do | pipe |
|
83
|
+
file_list.each { | pathname | pipe.puts pathname }
|
61
84
|
end
|
62
85
|
end
|
63
86
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-confident
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joe Yates
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-21 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|