#214: added ability to destroy branch
This commit is contained in:
parent
ddbaffdb13
commit
2e33f0038a
|
@ -59,7 +59,6 @@ GEM
|
|||
ancestry (1.3.0)
|
||||
activerecord (>= 2.3.14)
|
||||
angularjs-rails (1.0.7)
|
||||
angularjs-rails-resource (0.2.0)
|
||||
arel (3.0.2)
|
||||
attr_encrypted (1.2.1)
|
||||
encryptor (>= 1.1.1)
|
||||
|
@ -411,7 +410,6 @@ DEPENDENCIES
|
|||
airbrake (~> 3.1.2)
|
||||
ancestry (~> 1.3.0)
|
||||
angularjs-rails
|
||||
angularjs-rails-resource
|
||||
attr_encrypted (= 1.2.1)
|
||||
better_errors
|
||||
binding_of_caller
|
||||
|
|
|
@ -20,6 +20,10 @@ var ProjectRef = function(atts) {
|
|||
return '/' + project.fullname + '/diff/' + current_ref + '...' + self.ref;
|
||||
}
|
||||
|
||||
self.archive_path = function(project, type) {
|
||||
return '/' + project.fullname + '/archive/' + project.name + '-' + self.ref + '.' + type;
|
||||
}
|
||||
|
||||
//return the scope-safe instance
|
||||
return self;
|
||||
};
|
|
@ -23,6 +23,8 @@ class Api::V1::ProjectsController < Api::V1::BaseController
|
|||
end
|
||||
|
||||
def refs_list
|
||||
@refs = @project.repo.branches.sort_by(&:name) +
|
||||
@project.repo.tags.select{ |t| t.commit }.sort_by(&:name).reverse
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -3,6 +3,8 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
|||
before_filter lambda{redirect_to @project if params[:treeish] == @project.default_branch and params[:path].blank?}, :only => :show
|
||||
skip_before_filter :set_branch_and_tree, :set_treeish_and_path, :only => :archive
|
||||
|
||||
before_filter lambda { raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) }, :only => [:branch, :destroy]
|
||||
|
||||
def show
|
||||
render('empty') and return if @project.is_empty?
|
||||
@tree = @tree / @path if @path.present?
|
||||
|
@ -28,18 +30,15 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
|||
end
|
||||
|
||||
def tags
|
||||
@tags = @project.repo.tags.select{ |t| t.commit }.sort_by(&:name).reverse
|
||||
render 'refs'
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise Grit::NoSuchPathError unless @branch
|
||||
@project.delete_branch @branch.name
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
def branches
|
||||
raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) # get wrong branch name to nonempty project
|
||||
# @branches = @project.repo.branches.sort_by(&:name).select{ |b| b.name != @branch.name }.unshift(@branch).compact if @branch
|
||||
render 'refs'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
json.refs_list (@project.repo.branches + @project.repo.tags) do |json_grit, grit|
|
||||
json.refs_list @refs do |json_grit, grit|
|
||||
json_grit.ref grit.name
|
||||
json_grit.object do |json_object|
|
||||
json_object.type (grit.class.name =~ /Tag/ ? 'tag' : 'commit')
|
||||
json_object.sha grit.commit.id
|
||||
json_object.authored_date grit.commit.authored_date.strftime('%d.%m.%Y')
|
||||
end
|
||||
end
|
||||
json.url refs_list_api_v1_project_path(@project.id, :format => :json)
|
|
@ -1,10 +0,0 @@
|
|||
- subjects_name = action_name.to_s
|
||||
|
||||
%h3= t("layout.projects.#{subjects_name}")
|
||||
- if subject.blank?
|
||||
%p= t("layout.projects.no_#{subjects_name}")
|
||||
- elsif subject.count == 1
|
||||
%p= t("layout.projects.total_#{subjects_name.singularize}")
|
||||
- else
|
||||
%p= t("layout.projects.total_#{subjects_name}", :count => subject.count)
|
||||
.both
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
= render 'submenu'
|
||||
= render 'repo_block', :project => @project
|
||||
= render 'header', :subject => (@branches || @tags)
|
||||
|
||||
|
||||
%div{'ng-controller' => 'ProjectRefsController',
|
||||
'ng-init' => "init('#{@project.id}','#{@branch.try(:name)}')"}
|
||||
|
||||
%h3= t('layout.projects.branches')
|
||||
%p{'ng-show' => '!branches.length'}= t('layout.projects.no_branches')
|
||||
%p{'ng-show' => 'branches.length == 1'}= t('layout.projects.total_branch')
|
||||
%p{'ng-show' => 'branches.length > 1'}= t('layout.projects.total_branches', :count => '{{branches.length}}')
|
||||
.both
|
||||
Search:
|
||||
|
||||
%input{'ng-model' => 'query.ref'}
|
||||
.both
|
||||
|
||||
|
@ -23,16 +25,9 @@
|
|||
%li.text{'ng-show' => 'branch.ref == current_ref'}
|
||||
= t('layout.projects.base_branch')
|
||||
%li{'ng-hide' => 'branch.ref == current_ref'}
|
||||
%a{:href => '#', 'ng-click' => 'destroy(branch)'}= t('layout.projects.delete_branch')
|
||||
%a{:href => '', 'ng-click' => 'destroy(branch)'}
|
||||
= t('layout.projects.delete_branch')
|
||||
%li{'ng-hide' => 'branch.ref == current_ref'}
|
||||
%a{'ng-href' => '{{branch.diff_path(project, current_ref)}}' }= t('layout.projects.compare')
|
||||
%a{'ng-href' => '{{branch.diff_path(project, current_ref)}}' }
|
||||
= t('layout.projects.compare')
|
||||
|
||||
|
||||
- if @tags.present?
|
||||
%div#project-tags
|
||||
%ol.release-list
|
||||
= render :partial => 'tag', :collection => @tags
|
||||
- elsif false # @branches.present?
|
||||
%table#project-branches
|
||||
%tbody
|
||||
= render :partial => 'branch', :collection => @branches
|
|
@ -0,0 +1,27 @@
|
|||
-set_meta_tags :title => "#{title_object @project}"
|
||||
|
||||
= render 'submenu'
|
||||
= render 'repo_block', :project => @project
|
||||
|
||||
%div{'ng-controller' => 'ProjectRefsController', 'ng-init' => "init('#{@project.id}')"}
|
||||
|
||||
%h3= t('layout.projects.tags')
|
||||
%p{'ng-show' => '!tags.length'}= t('layout.projects.no_tags')
|
||||
%p{'ng-show' => 'tags.length == 1'}= t('layout.projects.total_tag')
|
||||
%p{'ng-show' => 'tags.length > 1'}= t('layout.projects.total_tags', :count => '{{tags.length}}')
|
||||
.both
|
||||
|
||||
%input{'ng-model' => 'query.ref'}
|
||||
.both
|
||||
|
||||
#project-tags
|
||||
%ol.release-list
|
||||
%li{'ng-repeat' => 'tag in tags | filter:query'}
|
||||
%a.detail-link{'ng-href' => '{{tag.path(project)}}' }
|
||||
= t('layout.projects.browse_code')
|
||||
- %w(zip tar.gz).each do |type|
|
||||
%a.detail-link{'ng-href' => "{{tag.archive_path(project, '#{type}')}}" }
|
||||
= t('layout.projects.source_code', :type => type)
|
||||
%p.name
|
||||
%b {{tag.ref}}
|
||||
.date {{tag.object.authored_date}}
|
|
@ -331,10 +331,9 @@ Rosa::Application.routes.draw do
|
|||
get '/tree/:treeish(/*path)' => "git/trees#show", :as => :tree, :format => false
|
||||
# Tags
|
||||
get '/tags' => "git/trees#tags", :as => :tags
|
||||
# delete '/tags/:treeish' => "git/trees#destroy", :as => :tags
|
||||
# Branches
|
||||
get '/branches/:treeish' => "git/trees#branches", :as => :branches
|
||||
# delete '/branches/:treeish' => "git/trees#destroy", :as => :branches
|
||||
delete '/branches/:treeish' => "git/trees#destroy", :as => :branches
|
||||
# Commits
|
||||
get '/commits/:treeish(/*path)' => "git/commits#index", :as => :commits, :format => false
|
||||
get '/commit/:id(.:format)' => "git/commits#show", :as => :commit
|
||||
|
|
|
@ -33,6 +33,11 @@ module Modules
|
|||
repo.tags.map(&:name) + repo.branches.map(&:name)
|
||||
end
|
||||
|
||||
def delete_branch(branch_name)
|
||||
repo.git.native(:branch, {}, '-D', branch_name)
|
||||
|
||||
end
|
||||
|
||||
def update_file(path, data, options = {})
|
||||
head = options[:head].to_s || default_branch
|
||||
actor = get_actor(options[:actor])
|
||||
|
|
Loading…
Reference in New Issue