spikegrobstein-git 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +274 -0
- data/lib/git.rb +148 -0
- data/lib/git/author.rb +14 -0
- data/lib/git/base.rb +560 -0
- data/lib/git/branch.rb +122 -0
- data/lib/git/branches.rb +71 -0
- data/lib/git/diff.rb +146 -0
- data/lib/git/index.rb +5 -0
- data/lib/git/lib.rb +847 -0
- data/lib/git/log.rb +128 -0
- data/lib/git/object.rb +282 -0
- data/lib/git/path.rb +31 -0
- data/lib/git/remote.rb +36 -0
- data/lib/git/repository.rb +6 -0
- data/lib/git/stash.rb +27 -0
- data/lib/git/stashes.rb +44 -0
- data/lib/git/status.rb +117 -0
- data/lib/git/version.rb +7 -0
- data/lib/git/working_directory.rb +4 -0
- metadata +109 -0
data/lib/git/stash.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Git
|
2
|
+
class Stash
|
3
|
+
|
4
|
+
def initialize(base, message, existing=false)
|
5
|
+
@base = base
|
6
|
+
@message = message
|
7
|
+
save unless existing
|
8
|
+
end
|
9
|
+
|
10
|
+
def save
|
11
|
+
@saved = @base.lib.stash_save(@message)
|
12
|
+
end
|
13
|
+
|
14
|
+
def saved?
|
15
|
+
@saved
|
16
|
+
end
|
17
|
+
|
18
|
+
def message
|
19
|
+
@message
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
message
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/git/stashes.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Git
|
2
|
+
|
3
|
+
# object that holds all the available stashes
|
4
|
+
class Stashes
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(base)
|
8
|
+
@stashes = []
|
9
|
+
|
10
|
+
@base = base
|
11
|
+
|
12
|
+
@base.lib.stashes_all.each do |id, message|
|
13
|
+
@stashes.unshift(Git::Stash.new(@base, message, true))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def save(message)
|
18
|
+
s = Git::Stash.new(@base, message)
|
19
|
+
@stashes.unshift(s) if s.saved?
|
20
|
+
end
|
21
|
+
|
22
|
+
def apply(index=nil)
|
23
|
+
@base.lib.stash_apply(index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def clear
|
27
|
+
@base.lib.stash_clear
|
28
|
+
@stashes = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def size
|
32
|
+
@stashes.size
|
33
|
+
end
|
34
|
+
|
35
|
+
def each(&block)
|
36
|
+
@stashes.each(&block)
|
37
|
+
end
|
38
|
+
|
39
|
+
def [](index)
|
40
|
+
@stashes[index.to_i]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/lib/git/status.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
module Git
|
2
|
+
|
3
|
+
class Status
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize(base)
|
7
|
+
@base = base
|
8
|
+
construct_status
|
9
|
+
end
|
10
|
+
|
11
|
+
def changed
|
12
|
+
@files.select { |k, f| f.type == 'M' }
|
13
|
+
end
|
14
|
+
|
15
|
+
def added
|
16
|
+
@files.select { |k, f| f.type == 'A' }
|
17
|
+
end
|
18
|
+
|
19
|
+
def deleted
|
20
|
+
@files.select { |k, f| f.type == 'D' }
|
21
|
+
end
|
22
|
+
|
23
|
+
def untracked
|
24
|
+
@files.select { |k, f| f.untracked }
|
25
|
+
end
|
26
|
+
|
27
|
+
def pretty
|
28
|
+
out = ''
|
29
|
+
self.each do |file|
|
30
|
+
out << pretty_file(file)
|
31
|
+
end
|
32
|
+
out << "\n"
|
33
|
+
out
|
34
|
+
end
|
35
|
+
|
36
|
+
def pretty_file(file)
|
37
|
+
<<FILE
|
38
|
+
#{file.path}
|
39
|
+
\tsha(r) #{file.sha_repo.to_s} #{file.mode_repo.to_s}
|
40
|
+
\tsha(i) #{file.sha_index.to_s} #{file.mode_index.to_s}
|
41
|
+
\ttype #{file.type.to_s}
|
42
|
+
\tstage #{file.stage.to_s}
|
43
|
+
\tuntrac #{file.untracked.to_s}
|
44
|
+
FILE
|
45
|
+
end
|
46
|
+
|
47
|
+
# enumerable method
|
48
|
+
|
49
|
+
def [](file)
|
50
|
+
@files[file]
|
51
|
+
end
|
52
|
+
|
53
|
+
def each(&block)
|
54
|
+
@files.values.each(&block)
|
55
|
+
end
|
56
|
+
|
57
|
+
class StatusFile
|
58
|
+
attr_accessor :path, :type, :stage, :untracked
|
59
|
+
attr_accessor :mode_index, :mode_repo
|
60
|
+
attr_accessor :sha_index, :sha_repo
|
61
|
+
|
62
|
+
def initialize(base, hash)
|
63
|
+
@base = base
|
64
|
+
@path = hash[:path]
|
65
|
+
@type = hash[:type]
|
66
|
+
@stage = hash[:stage]
|
67
|
+
@mode_index = hash[:mode_index]
|
68
|
+
@mode_repo = hash[:mode_repo]
|
69
|
+
@sha_index = hash[:sha_index]
|
70
|
+
@sha_repo = hash[:sha_repo]
|
71
|
+
@untracked = hash[:untracked]
|
72
|
+
end
|
73
|
+
|
74
|
+
def blob(type = :index)
|
75
|
+
if type == :repo
|
76
|
+
@base.object(@sha_repo)
|
77
|
+
else
|
78
|
+
@base.object(@sha_index) rescue @base.object(@sha_repo)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def construct_status
|
88
|
+
@files = @base.lib.ls_files
|
89
|
+
ignore = @base.lib.ignored_files
|
90
|
+
|
91
|
+
# find untracked in working dir
|
92
|
+
Dir.chdir(@base.dir.path) do
|
93
|
+
Dir.glob('**/*', File::FNM_DOTMATCH) do |file|
|
94
|
+
next if @files[file] || File.directory?(file) || ignore.include?(file) || file =~ /^.git\/.+/
|
95
|
+
|
96
|
+
@files[file] = {:path => file, :untracked => true}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# find modified in tree
|
101
|
+
@base.lib.diff_files.each do |path, data|
|
102
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
103
|
+
end
|
104
|
+
|
105
|
+
# find added but not committed - new files
|
106
|
+
@base.lib.diff_index('HEAD').each do |path, data|
|
107
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
108
|
+
end
|
109
|
+
|
110
|
+
@files.each do |k, file_hash|
|
111
|
+
@files[k] = StatusFile.new(@base, file_hash)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
data/lib/git/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spikegrobstein-git
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Chacon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email: schacon@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- README.md
|
61
|
+
files:
|
62
|
+
- LICENSE
|
63
|
+
- lib/git.rb
|
64
|
+
- lib/git/author.rb
|
65
|
+
- lib/git/base.rb
|
66
|
+
- lib/git/branch.rb
|
67
|
+
- lib/git/branches.rb
|
68
|
+
- lib/git/diff.rb
|
69
|
+
- lib/git/index.rb
|
70
|
+
- lib/git/lib.rb
|
71
|
+
- lib/git/log.rb
|
72
|
+
- lib/git/object.rb
|
73
|
+
- lib/git/path.rb
|
74
|
+
- lib/git/remote.rb
|
75
|
+
- lib/git/repository.rb
|
76
|
+
- lib/git/stash.rb
|
77
|
+
- lib/git/stashes.rb
|
78
|
+
- lib/git/status.rb
|
79
|
+
- lib/git/version.rb
|
80
|
+
- lib/git/working_directory.rb
|
81
|
+
- README.md
|
82
|
+
homepage: http://github.com/schacon/ruby-git
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- --charset=UTF-8
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements:
|
102
|
+
- git 1.6.0.0, or greater
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.0.14
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Ruby/Git is a Ruby library that can be used to create, read and manipulate
|
108
|
+
Git repositories by wrapping system calls to the git binary.
|
109
|
+
test_files: []
|