git-glimmer 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +106 -0
- data/CONTRIBUTING.md +144 -0
- data/LICENSE +21 -0
- data/MAINTAINERS.md +9 -0
- data/README.md +300 -0
- data/lib/git-glimmer.rb +1 -0
- data/lib/git.rb +167 -0
- data/lib/git/author.rb +14 -0
- data/lib/git/base.rb +551 -0
- data/lib/git/base/factory.rb +83 -0
- data/lib/git/branch.rb +126 -0
- data/lib/git/branches.rb +71 -0
- data/lib/git/config.rb +22 -0
- data/lib/git/diff.rb +154 -0
- data/lib/git/index.rb +5 -0
- data/lib/git/lib.rb +1091 -0
- data/lib/git/log.rb +128 -0
- data/lib/git/object.rb +312 -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 +55 -0
- data/lib/git/status.rb +199 -0
- data/lib/git/version.rb +5 -0
- data/lib/git/working_directory.rb +4 -0
- metadata +133 -0
data/lib/git/remote.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Git
|
2
|
+
class Remote < Path
|
3
|
+
|
4
|
+
attr_accessor :name, :url, :fetch_opts
|
5
|
+
|
6
|
+
def initialize(base, name)
|
7
|
+
@base = base
|
8
|
+
config = @base.lib.config_remote(name)
|
9
|
+
@name = name
|
10
|
+
@url = config['url']
|
11
|
+
@fetch_opts = config['fetch']
|
12
|
+
end
|
13
|
+
|
14
|
+
def fetch(opts={})
|
15
|
+
@base.fetch(@name, opts)
|
16
|
+
end
|
17
|
+
|
18
|
+
# merge this remote locally
|
19
|
+
def merge(branch = 'master')
|
20
|
+
@base.merge("#{@name}/#{branch}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def branch(branch = 'master')
|
24
|
+
Git::Branch.new(@base, "#{@name}/#{branch}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove
|
28
|
+
@base.lib.remote_remove(@name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
@name
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
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,55 @@
|
|
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
|
+
#
|
18
|
+
# Returns an multi-dimensional Array of elements that have been stash saved.
|
19
|
+
# Array is based on position and name. See Example
|
20
|
+
#
|
21
|
+
# @example Returns Array of items that have been stashed
|
22
|
+
# .all - [0, "testing-stash-all"]]
|
23
|
+
# @return [Array]
|
24
|
+
def all
|
25
|
+
@base.lib.stashes_all
|
26
|
+
end
|
27
|
+
|
28
|
+
def save(message)
|
29
|
+
s = Git::Stash.new(@base, message)
|
30
|
+
@stashes.unshift(s) if s.saved?
|
31
|
+
end
|
32
|
+
|
33
|
+
def apply(index=nil)
|
34
|
+
@base.lib.stash_apply(index)
|
35
|
+
end
|
36
|
+
|
37
|
+
def clear
|
38
|
+
@base.lib.stash_clear
|
39
|
+
@stashes = []
|
40
|
+
end
|
41
|
+
|
42
|
+
def size
|
43
|
+
@stashes.size
|
44
|
+
end
|
45
|
+
|
46
|
+
def each(&block)
|
47
|
+
@stashes.each(&block)
|
48
|
+
end
|
49
|
+
|
50
|
+
def [](index)
|
51
|
+
@stashes[index.to_i]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/lib/git/status.rb
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
module Git
|
2
|
+
#
|
3
|
+
# A class for git status
|
4
|
+
#
|
5
|
+
class Status
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def initialize(base)
|
9
|
+
@base = base
|
10
|
+
construct_status
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Returns an Enumerable containing files that have changed from the
|
15
|
+
# git base directory
|
16
|
+
#
|
17
|
+
# @return [Enumerable]
|
18
|
+
def changed
|
19
|
+
@files.select { |_k, f| f.type == 'M' }
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Determines whether the given file has been changed.
|
24
|
+
# File path starts at git base directory
|
25
|
+
#
|
26
|
+
# @param file [String] The name of the file.
|
27
|
+
# @example Check if lib/git.rb has changed.
|
28
|
+
# changed?('lib/git.rb')
|
29
|
+
# @return [Boolean]
|
30
|
+
def changed?(file)
|
31
|
+
changed.member?(file)
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# Returns an Enumerable containing files that have been added.
|
36
|
+
# File path starts at git base directory
|
37
|
+
#
|
38
|
+
# @return [Enumerable]
|
39
|
+
def added
|
40
|
+
@files.select { |_k, f| f.type == 'A' }
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Determines whether the given file has been added to the repository
|
45
|
+
# File path starts at git base directory
|
46
|
+
#
|
47
|
+
# @param file [String] The name of the file.
|
48
|
+
# @example Check if lib/git.rb is added.
|
49
|
+
# added?('lib/git.rb')
|
50
|
+
# @return [Boolean]
|
51
|
+
def added?(file)
|
52
|
+
added.member?(file)
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Returns an Enumerable containing files that have been deleted.
|
57
|
+
# File path starts at git base directory
|
58
|
+
#
|
59
|
+
# @return [Enumerable]
|
60
|
+
def deleted
|
61
|
+
@files.select { |_k, f| f.type == 'D' }
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Determines whether the given file has been deleted from the repository
|
66
|
+
# File path starts at git base directory
|
67
|
+
#
|
68
|
+
# @param file [String] The name of the file.
|
69
|
+
# @example Check if lib/git.rb is deleted.
|
70
|
+
# deleted?('lib/git.rb')
|
71
|
+
# @return [Boolean]
|
72
|
+
def deleted?(file)
|
73
|
+
deleted.member?(file)
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Returns an Enumerable containing files that are not tracked in git.
|
78
|
+
# File path starts at git base directory
|
79
|
+
#
|
80
|
+
# @return [Enumerable]
|
81
|
+
def untracked
|
82
|
+
@files.select { |_k, f| f.untracked }
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# Determines whether the given file has is tracked by git.
|
87
|
+
# File path starts at git base directory
|
88
|
+
#
|
89
|
+
# @param file [String] The name of the file.
|
90
|
+
# @example Check if lib/git.rb is an untracked file.
|
91
|
+
# untracked?('lib/git.rb')
|
92
|
+
# @return [Boolean]
|
93
|
+
def untracked?(file)
|
94
|
+
untracked.member?(file)
|
95
|
+
end
|
96
|
+
|
97
|
+
def pretty
|
98
|
+
out = ''
|
99
|
+
each do |file|
|
100
|
+
out << pretty_file(file)
|
101
|
+
end
|
102
|
+
out << "\n"
|
103
|
+
out
|
104
|
+
end
|
105
|
+
|
106
|
+
def pretty_file(file)
|
107
|
+
<<-FILE.strip_heredoc
|
108
|
+
#{file.path}
|
109
|
+
\tsha(r) #{file.sha_repo} #{file.mode_repo}
|
110
|
+
\tsha(i) #{file.sha_index} #{file.mode_index}
|
111
|
+
\ttype #{file.type}
|
112
|
+
\tstage #{file.stage}
|
113
|
+
\tuntrac #{file.untracked}
|
114
|
+
FILE
|
115
|
+
end
|
116
|
+
|
117
|
+
# enumerable method
|
118
|
+
|
119
|
+
def [](file)
|
120
|
+
@files[file]
|
121
|
+
end
|
122
|
+
|
123
|
+
def each(&block)
|
124
|
+
@files.values.each(&block)
|
125
|
+
end
|
126
|
+
|
127
|
+
# subclass that does heavy lifting
|
128
|
+
class StatusFile
|
129
|
+
attr_accessor :path, :type, :stage, :untracked
|
130
|
+
attr_accessor :mode_index, :mode_repo
|
131
|
+
attr_accessor :sha_index, :sha_repo
|
132
|
+
|
133
|
+
def initialize(base, hash)
|
134
|
+
@base = base
|
135
|
+
@path = hash[:path]
|
136
|
+
@type = hash[:type]
|
137
|
+
@stage = hash[:stage]
|
138
|
+
@mode_index = hash[:mode_index]
|
139
|
+
@mode_repo = hash[:mode_repo]
|
140
|
+
@sha_index = hash[:sha_index]
|
141
|
+
@sha_repo = hash[:sha_repo]
|
142
|
+
@untracked = hash[:untracked]
|
143
|
+
end
|
144
|
+
|
145
|
+
def blob(type = :index)
|
146
|
+
if type == :repo
|
147
|
+
@base.object(@sha_repo)
|
148
|
+
else
|
149
|
+
begin
|
150
|
+
@base.object(@sha_index)
|
151
|
+
rescue
|
152
|
+
@base.object(@sha_repo)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def construct_status
|
161
|
+
@files = @base.lib.ls_files
|
162
|
+
|
163
|
+
fetch_untracked
|
164
|
+
fetch_modified
|
165
|
+
fetch_added
|
166
|
+
|
167
|
+
@files.each do |k, file_hash|
|
168
|
+
@files[k] = StatusFile.new(@base, file_hash)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def fetch_untracked
|
173
|
+
ignore = @base.lib.ignored_files
|
174
|
+
|
175
|
+
Dir.chdir(@base.dir.path) do
|
176
|
+
Dir.glob('**/*', File::FNM_DOTMATCH) do |file|
|
177
|
+
next if @files[file] || File.directory?(file) ||
|
178
|
+
ignore.include?(file) || file =~ %r{^.git\/.+}
|
179
|
+
|
180
|
+
@files[file] = { path: file, untracked: true }
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def fetch_modified
|
186
|
+
# find modified in tree
|
187
|
+
@base.lib.diff_files.each do |path, data|
|
188
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def fetch_added
|
193
|
+
# find added but not committed - new files
|
194
|
+
@base.lib.diff_index('HEAD').each do |path, data|
|
195
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
data/lib/git/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-glimmer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Maleh, Scott Chacon and others
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rchardet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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: rdoc
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '4'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '4'
|
75
|
+
description:
|
76
|
+
email: andy.am@gmail.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files:
|
80
|
+
- README.md
|
81
|
+
files:
|
82
|
+
- CHANGELOG.md
|
83
|
+
- CONTRIBUTING.md
|
84
|
+
- LICENSE
|
85
|
+
- MAINTAINERS.md
|
86
|
+
- README.md
|
87
|
+
- lib/git-glimmer.rb
|
88
|
+
- lib/git.rb
|
89
|
+
- lib/git/author.rb
|
90
|
+
- lib/git/base.rb
|
91
|
+
- lib/git/base/factory.rb
|
92
|
+
- lib/git/branch.rb
|
93
|
+
- lib/git/branches.rb
|
94
|
+
- lib/git/config.rb
|
95
|
+
- lib/git/diff.rb
|
96
|
+
- lib/git/index.rb
|
97
|
+
- lib/git/lib.rb
|
98
|
+
- lib/git/log.rb
|
99
|
+
- lib/git/object.rb
|
100
|
+
- lib/git/path.rb
|
101
|
+
- lib/git/remote.rb
|
102
|
+
- lib/git/repository.rb
|
103
|
+
- lib/git/stash.rb
|
104
|
+
- lib/git/stashes.rb
|
105
|
+
- lib/git/status.rb
|
106
|
+
- lib/git/version.rb
|
107
|
+
- lib/git/working_directory.rb
|
108
|
+
homepage: https://github.com/AndyObtiva/ruby-git
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options:
|
114
|
+
- "--charset=UTF-8"
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '1.9'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements:
|
128
|
+
- git 1.6.0.0, or greater
|
129
|
+
rubygems_version: 3.1.2
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Ruby/Git with fixes to use in Glimmer (Ruby Desktop Development GUI Library)
|
133
|
+
test_files: []
|