#222: removed #restore_branch method
This commit is contained in:
parent
f69013329a
commit
c9b7f890fa
|
@ -35,7 +35,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def restore_branch
|
def restore_branch
|
||||||
status = @project.restore_branch(@treeish, params[:sha], current_user) ? 200 : 422
|
status = @project.create_branch(@treeish, params[:sha], current_user) ? 200 : 422
|
||||||
render :nothing => true, :status => status
|
render :nothing => true, :status => status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,18 +33,15 @@ module Modules
|
||||||
repo.tags.map(&:name) + repo.branches.map(&:name)
|
repo.tags.map(&:name) + repo.branches.map(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: return something else instead of empty string on success and error
|
def create_branch(new_ref, from_ref, user)
|
||||||
def restore_branch(branch, sha, user)
|
return false if new_ref.blank? || from_ref.blank? || !(from_commit = repo.commit(from_ref))
|
||||||
return false if branch.blank? || sha.blank? || repo.commit(sha).nil?
|
status, out, err = repo.git.native(:branch, {:process_info => true}, new_ref, from_commit.id)
|
||||||
repo.git.native(:branch, {}, branch, sha)
|
if status == 0
|
||||||
Resque.enqueue(GitHook, owner.uname, name, sha, GitHook::ZERO, "refs/heads/#{branch}", 'commit', "user-#{user.id}", nil)
|
Resque.enqueue(GitHook, owner.uname, name, from_commit.id, GitHook::ZERO, "refs/heads/#{new_ref}", 'commit', "user-#{user.id}", nil)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
return false
|
||||||
|
|
||||||
def create_branch(new_ref, from_ref, user)
|
|
||||||
branch = repo.branches.detect{|b| b.name == from_ref}
|
|
||||||
return false if !branch || repo.branches.one?{|b| b.name == new_ref}
|
|
||||||
restore_branch new_ref, branch.commit.id, user
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_branch(branch, user)
|
def delete_branch(branch, user)
|
||||||
|
|
Loading…
Reference in New Issue