#214: updated logic of deleting of branch

This commit is contained in:
Vokhmin Alexey V 2013-07-11 17:50:22 +04:00
parent ff646af607
commit e096fc1bde
4 changed files with 10 additions and 4 deletions

View File

@ -17,6 +17,8 @@ RosaABF.controller('ProjectRefsController', function($scope, $http, $location, A
$scope.getRefs = function() { $scope.getRefs = function() {
//returns [ProjectRef, ProjectRef, ...] //returns [ProjectRef, ProjectRef, ...]
ApiProject.refs($scope.project_id, function(results){ ApiProject.refs($scope.project_id, function(results){
$scope.tags = [];
$scope.branches = [];
_.each(results, function(result){ _.each(results, function(result){
if (result.isTag) { if (result.isTag) {
if (result.ref == $scope.current_ref) { if (result.ref == $scope.current_ref) {
@ -36,9 +38,9 @@ RosaABF.controller('ProjectRefsController', function($scope, $http, $location, A
}; };
$scope.destroy = function(branch) { $scope.destroy = function(branch) {
var path = $location.$$absUrl.replace(/\/[\w\-]+$/, '') + '/' + branch.name; $http.delete(branch.delete_path($scope.project)).success(function(data) {
$http.delete(path).success(function(data) {
$scope.getRefs(); $scope.getRefs();
}); });
} }
}); });

View File

@ -16,6 +16,10 @@ var ProjectRef = function(atts) {
return '/' + project.fullname + '/tree/' + self.ref; return '/' + project.fullname + '/tree/' + self.ref;
} }
self.delete_path = function(project) {
return '/' + project.fullname + '/branches/' + self.ref;
}
self.diff_path = function(project, current_ref) { self.diff_path = function(project, current_ref) {
return '/' + project.fullname + '/diff/' + current_ref + '...' + self.ref; return '/' + project.fullname + '/diff/' + current_ref + '...' + self.ref;
} }

View File

@ -34,7 +34,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController
def destroy def destroy
raise Grit::NoSuchPathError unless @branch raise Grit::NoSuchPathError unless @branch
@project.delete_branch @branch.name @project.delete_branch @branch, current_user
render :nothing => true render :nothing => true
end end

View File

@ -35,7 +35,7 @@ module Modules
def delete_branch(branch, user) def delete_branch(branch, user)
message = repo.git.native(:branch, {}, '-D', branch.name) message = repo.git.native(:branch, {}, '-D', branch.name)
Resque.enqueue(GitHook, owner.uname, name, GitHook::ZERO, sha1, "refs/heads/#{branch.name}", 'commit', "user-#{user.id}", message) Resque.enqueue(GitHook,owner.uname, name, GitHook::ZERO, branch.commit.id, "refs/heads/#{branch.name}", 'commit', "user-#{user.id}", message)
end end
def update_file(path, data, options = {}) def update_file(path, data, options = {})