Skip to content

Commit 9d4b755

Browse files
committed
Added show_files and list directory suport
1 parent b79de3a commit 9d4b755

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ And here are the operations that will need to write to your git repository.
173173
g.branch(name).in_branch(message) { # add files } # auto-commits
174174
g.merge('new_branch')
175175
g.merge('origin/remote_branch')
176+
<<<<<<< HEAD
176177
g.merge(g.branch('master'))
178+
=======
179+
g.merge(b.branch('master'))
180+
>>>>>>> Added show_files and list directory suport
177181
g.merge([branch1, branch2])
178182

179183
r = g.add_remote(name, uri) # Git::Remote

lib/git/base.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def diff(objectish = 'HEAD', obj2 = nil)
244244
end
245245

246246
# adds files from the working directory to the git repository
247-
def add(path = '.')
248-
self.lib.add(path)
247+
def add(path = '.',opts = {})
248+
self.lib.add(path,opts)
249249
end
250250

251251
# removes file(s) from the git repository
@@ -292,6 +292,10 @@ def checkout_file(version, file)
292292
self.lib.checkout_file(version,file)
293293
end
294294

295+
def show_file(version,file)
296+
self.lib.show_file(version,file)
297+
end
298+
295299
# fetches changes from a remote branch - this does not modify the working directory,
296300
# it just gets the changes from the remote if there are any
297301
def fetch(remote = 'origin')

lib/git/lib.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ def global_config_set(name, value)
392392
command('config', ['--global', name, value], false)
393393
end
394394

395-
def add(path = '.')
396-
arr_opts = ['--']
395+
def add(path = '.', opts={})
396+
arr_opts = []
397+
arr_opts << ['-A'] if opts[:add_remove]
398+
arr_opts << ['--']
397399
if path.is_a?(Array)
398400
arr_opts += path
399401
else
@@ -498,6 +500,12 @@ def checkout_file(version, file)
498500
arr_opts << file
499501
command('checkout', arr_opts)
500502
end
503+
504+
def show_file(version, file)
505+
arr_opts = []
506+
arr_opts << "#{version}:#{file}"
507+
command('show', arr_opts)
508+
end
501509

502510
def merge(branch, message = nil)
503511
arr_opts = []

0 commit comments

Comments
 (0)