From e096fc1bdef080a9db9dcb44928bf21be68312d4 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 11 Jul 2013 17:50:22 +0400 Subject: [PATCH] #214: updated logic of deleting of branch --- .../angularjs/controllers/project_refs_controller.js | 6 ++++-- app/assets/javascripts/angularjs/models/project_ref.js | 4 ++++ app/controllers/projects/git/trees_controller.rb | 2 +- lib/modules/models/git.rb | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/angularjs/controllers/project_refs_controller.js b/app/assets/javascripts/angularjs/controllers/project_refs_controller.js index 56341a452..c87bb9d11 100644 --- a/app/assets/javascripts/angularjs/controllers/project_refs_controller.js +++ b/app/assets/javascripts/angularjs/controllers/project_refs_controller.js @@ -17,6 +17,8 @@ RosaABF.controller('ProjectRefsController', function($scope, $http, $location, A $scope.getRefs = function() { //returns [ProjectRef, ProjectRef, ...] ApiProject.refs($scope.project_id, function(results){ + $scope.tags = []; + $scope.branches = []; _.each(results, function(result){ if (result.isTag) { if (result.ref == $scope.current_ref) { @@ -36,9 +38,9 @@ RosaABF.controller('ProjectRefsController', function($scope, $http, $location, A }; $scope.destroy = function(branch) { - var path = $location.$$absUrl.replace(/\/[\w\-]+$/, '') + '/' + branch.name; - $http.delete(path).success(function(data) { + $http.delete(branch.delete_path($scope.project)).success(function(data) { $scope.getRefs(); }); } + }); \ No newline at end of file diff --git a/app/assets/javascripts/angularjs/models/project_ref.js b/app/assets/javascripts/angularjs/models/project_ref.js index b13b40dc9..bbd878048 100644 --- a/app/assets/javascripts/angularjs/models/project_ref.js +++ b/app/assets/javascripts/angularjs/models/project_ref.js @@ -16,6 +16,10 @@ var ProjectRef = function(atts) { return '/' + project.fullname + '/tree/' + self.ref; } + self.delete_path = function(project) { + return '/' + project.fullname + '/branches/' + self.ref; + } + self.diff_path = function(project, current_ref) { return '/' + project.fullname + '/diff/' + current_ref + '...' + self.ref; } diff --git a/app/controllers/projects/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb index 2cb5409e4..bddf8166a 100644 --- a/app/controllers/projects/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -34,7 +34,7 @@ class Projects::Git::TreesController < Projects::Git::BaseController def destroy raise Grit::NoSuchPathError unless @branch - @project.delete_branch @branch.name + @project.delete_branch @branch, current_user render :nothing => true end diff --git a/lib/modules/models/git.rb b/lib/modules/models/git.rb index 5e48813b6..d453ce8f0 100644 --- a/lib/modules/models/git.rb +++ b/lib/modules/models/git.rb @@ -35,7 +35,7 @@ module Modules def delete_branch(branch, user) 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 def update_file(path, data, options = {})