Skip to content

Additions for serving versioned files from rails/Automatically untrack deleted files. #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ And here are the operations that will need to write to your git repository.
g.branch(name).in_branch(message) { # add files } # auto-commits
g.merge('new_branch')
g.merge('origin/remote_branch')
<<<<<<< HEAD
g.merge(g.branch('master'))
=======
g.merge(b.branch('master'))
>>>>>>> Added show_files and list directory suport
g.merge([branch1, branch2])

r = g.add_remote(name, uri) # Git::Remote
Expand Down
13 changes: 10 additions & 3 deletions lib/git/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def diff(objectish = 'HEAD', obj2 = nil)
end

# adds files from the working directory to the git repository
def add(path = '.')
self.lib.add(path)
def add(path = '.',opts = {})
self.lib.add(path,opts)
end

# removes file(s) from the git repository
Expand Down Expand Up @@ -292,6 +292,10 @@ def checkout_file(version, file)
self.lib.checkout_file(version,file)
end

def show_file(version,file)
self.lib.show_file(version,file)
end

# fetches changes from a remote branch - this does not modify the working directory,
# it just gets the changes from the remote if there are any
def fetch(remote = 'origin')
Expand Down Expand Up @@ -473,7 +477,10 @@ def current_branch
self.lib.branch_current
end


def clean
puts "cleaning"
self.lib.clean
end
end

end
26 changes: 21 additions & 5 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def initialize(base = nil, logger = nil)
def init
command('init')
end

def clean
command('clean -f')
end

# tries to clone the given repo
#
Expand Down Expand Up @@ -103,7 +107,7 @@ def revparse(string)
return File.read(rev).chomp if rev
command('rev-parse', string)
end

def namerev(string)
command('name-rev', string).split[1]
end
Expand Down Expand Up @@ -392,8 +396,10 @@ def global_config_set(name, value)
command('config', ['--global', name, value], false)
end

def add(path = '.')
arr_opts = ['--']
def add(path = '.', opts={})
arr_opts = []
arr_opts << ['-A'] if opts[:add_remove]
arr_opts << ['--']
if path.is_a?(Array)
arr_opts += path
else
Expand Down Expand Up @@ -486,8 +492,12 @@ def branch_delete(branch)
def checkout(branch, opts = {})
arr_opts = []
arr_opts << '-f' if opts[:force]
arr_opts << '-b' << opts[:new_branch] if opts[:new_branch]
arr_opts << branch
if( opts[:force_branch] )
arr_opts << '-B' << opts[:force_branch]
else
arr_opts << '-b' << opts[:new_branch] if opts[:new_branch]
end
arr_opts << branch if branch

command('checkout', arr_opts)
end
Expand All @@ -498,6 +508,12 @@ def checkout_file(version, file)
arr_opts << file
command('checkout', arr_opts)
end

def show_file(version, file)
arr_opts = []
arr_opts << "#{version}:#{file}"
command('show', arr_opts)
end

def merge(branch, message = nil)
arr_opts = []
Expand Down