项目issue关联commit(未完成)

This commit is contained in:
huang 2016-12-01 14:21:40 +08:00
parent 890b0e80fd
commit bbc8d11f80
11 changed files with 62 additions and 13 deletions

View File

@ -57,6 +57,21 @@ class IssuesController < ApplicationController
helper :project_score
include ApplicationHelper
# issue和代码提交id关联模块 --> over
# 获取某个项目的commit_ids
def issue_commits
project = Project.find(@issue.project_id)
begin
g = Gitlab.commits(project.gpid)
g_project = g.project(project.gpid)
@rev = params[:rev].nil? ? g_project.default_branch : params[:rev]
@commits = g.g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev)
rescue Exception => e
puts e
end
end
# over
def index
# 顶部导航
@project_menu_type = 2

View File

@ -0,0 +1,5 @@
class CommitIssues < ActiveRecord::Base
attr_accessible :commit_id, :issue_id, :project_id
# 之所以没建立关联表主要是应为commit_id是直接通过api获取的不存在trustie端
has_many :issues
end

View File

@ -133,8 +133,9 @@
:onchange => "PrecentChange(this.value)",
:class => "w150" %>
<% end %>
<li class=" clear">完成度</li>
</li>
<li class="clear">完成度</li>
<li class="clear"><span>关联Commit</span><%= link_to "<span class='btn-commit btn-blue mt-2 fr'>+</span>".html_safe, issue_commits_issues_path %></li>
</ul>
<% end %>
<script>

View File

View File

@ -0,0 +1,2 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'issues/issue_commits') %>";
pop_box_new(htmlvalue,460,190);

View File

@ -950,6 +950,7 @@ RedmineApp::Application.routes.draw do
collection do
match 'bulk_edit', :via => [:get, :post]
post 'bulk_update'
get 'issue_commits'
end
member do
post 'add_journal'

View File

@ -0,0 +1,11 @@
class CreateCommitIssues < ActiveRecord::Migration
def change
create_table :commit_issues do |t|
t.string :commit_id
t.integer :issue_id
t.integer :project_id
t.timestamps
end
end
end

View File

@ -20,6 +20,7 @@ input.radio-width90{ width: 90px; }
.muban_icons_blue{font-size: 12px;padding: 0 5px;border-radius: 3px;line-height: 14px;color: #3b94d6;border: 1px solid #3b94d6;}
/*模板buttons 20161013byLB*/
.btn{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 30px;line-height: 30px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; }
.btn-commit{display: inline-block;border:none; padding:0 10px;color: #333;background: #e1e1e1; text-align:center;font-size: 12px; height: 20px;line-height: 20px;-webkit-border-radius: 3px;-moz-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; }
.btn:hover{background: #c3c3c3; color: #333;}
.btn-grey{background: #d9d9d9; color: #656565;}
.btn-grey:hover{background: #717171; color: #fff;}

View File

@ -0,0 +1,8 @@
FactoryGirl.define do
factory :commit_issue, :class => 'CommitIssues' do
commit_id "MyString"
issue_id 1
project_id 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CommitIssues, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end