Commit e6d2e5696186cc81b7d9a12af25e00528ca2cc30
1 parent
8f621c9e
Exists in
master
and in
4 other branches
Issue tracker field added to projects
Showing
9 changed files
with
69 additions
and
315 deletions
Show diff stats
app/helpers/issues_helper.rb
... | ... | @@ -40,4 +40,31 @@ module IssuesHelper |
40 | 40 | def issues_active_milestones |
41 | 41 | @project.milestones.active.order("id desc").all |
42 | 42 | end |
43 | + | |
44 | + def url_for_issue(issue_id) | |
45 | + if @project.issues_tracker == Project.issues_tracker.default_value | |
46 | + url = project_issue_url project_id: @project, id: issue_id | |
47 | + else | |
48 | + url = Settings[:issues_tracker][@project.issues_tracker]["issues_url"] | |
49 | + url.gsub(':id', issue_id.to_s).gsub(':project_id', @project.id.to_s) | |
50 | + end | |
51 | + end | |
52 | + | |
53 | + def title_for_issue(issue_id) | |
54 | + if issue = @project.issues.where(id: issue_id).first | |
55 | + issue.title | |
56 | + else | |
57 | + "" | |
58 | + end | |
59 | + end | |
60 | + | |
61 | + def issue_exists?(issue_id) | |
62 | + return false if @project.nil? | |
63 | + | |
64 | + if @project.issues_tracker == Project.issues_tracker.default_value | |
65 | + @project.issues.where(id: issue_id).first.present? | |
66 | + else | |
67 | + true | |
68 | + end | |
69 | + end | |
43 | 70 | end | ... | ... |
app/models/project.rb
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | # creator_id :integer |
12 | 12 | # default_branch :string(255) |
13 | 13 | # issues_enabled :boolean default(TRUE), not null |
14 | +# issues_tracker :string not null | |
14 | 15 | # wall_enabled :boolean default(TRUE), not null |
15 | 16 | # merge_requests_enabled :boolean default(TRUE), not null |
16 | 17 | # wiki_enabled :boolean default(TRUE), not null |
... | ... | @@ -22,10 +23,11 @@ require "grit" |
22 | 23 | |
23 | 24 | class Project < ActiveRecord::Base |
24 | 25 | include Gitolited |
26 | + extend Enumerize | |
25 | 27 | |
26 | 28 | class TransferError < StandardError; end |
27 | 29 | |
28 | - attr_accessible :name, :path, :description, :default_branch, | |
30 | + attr_accessible :name, :path, :description, :default_branch, :issues_tracker, | |
29 | 31 | :issues_enabled, :wall_enabled, :merge_requests_enabled, |
30 | 32 | :wiki_enabled, :public, :import_url, as: [:default, :admin] |
31 | 33 | |
... | ... | @@ -93,6 +95,8 @@ class Project < ActiveRecord::Base |
93 | 95 | scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } |
94 | 96 | scope :public_only, -> { where(public: true) } |
95 | 97 | |
98 | + enumerize :issues_tracker, :in => (Settings[:issues_tracker].keys).append(:gitlab), :default => :gitlab | |
99 | + | |
96 | 100 | class << self |
97 | 101 | def abandoned |
98 | 102 | project_ids = Event.select('max(created_at) as latest_date, project_id'). | ... | ... |
app/views/projects/_form.html.haml
... | ... | @@ -25,6 +25,10 @@ |
25 | 25 | %span.descr Lightweight issue tracking system for this project |
26 | 26 | |
27 | 27 | .control-group |
28 | + = f.label :issues_tracker, "Issues tracker", class: 'control-label' | |
29 | + .input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled }) | |
30 | + | |
31 | + .control-group | |
28 | 32 | = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label' |
29 | 33 | .controls |
30 | 34 | = f.check_box :merge_requests_enabled | ... | ... |
config/gitlab.yml.example
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | # 2. Replace gitlab -> host with your domain |
8 | 8 | # 3. Replace gitlab -> email_from |
9 | 9 | |
10 | +<<<<<<< HEAD | |
10 | 11 | production: &base |
11 | 12 | # |
12 | 13 | # 1. GitLab app settings |
... | ... | @@ -37,6 +38,11 @@ production: &base |
37 | 38 | # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. |
38 | 39 | # username_changing_enabled: false # default: true - User can change her username/namespace |
39 | 40 | |
41 | + ## Available issues trackers | |
42 | + issues_tracker: | |
43 | + redmine: | |
44 | + issues_url: "http://redmine.sample/issues/:id" | |
45 | + | |
40 | 46 | ## Gravatar |
41 | 47 | gravatar: |
42 | 48 | enabled: true # Use user avatar images from Gravatar.com (default: true) | ... | ... |
db/migrate/20130123114545_add_issues_tracker_to_project.rb
0 → 100644
db/schema.rb
... | ... | @@ -1,312 +0,0 @@ |
1 | -# encoding: UTF-8 | |
2 | -# This file is auto-generated from the current state of the database. Instead | |
3 | -# of editing this file, please use the migrations feature of Active Record to | |
4 | -# incrementally modify your database, and then regenerate this schema definition. | |
5 | -# | |
6 | -# Note that this schema.rb definition is the authoritative source for your | |
7 | -# database schema. If you need to create the application database on another | |
8 | -# system, you should be using db:schema:load, not running all the migrations | |
9 | -# from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
10 | -# you'll amass, the slower it'll run and the greater likelihood for issues). | |
11 | -# | |
12 | -# It's strongly recommended to check this file into your version control system. | |
13 | - | |
14 | -ActiveRecord::Schema.define(:version => 20130220133245) do | |
15 | - | |
16 | - create_table "events", :force => true do |t| | |
17 | - t.string "target_type" | |
18 | - t.integer "target_id" | |
19 | - t.string "title" | |
20 | - t.text "data" | |
21 | - t.integer "project_id" | |
22 | - t.datetime "created_at", :null => false | |
23 | - t.datetime "updated_at", :null => false | |
24 | - t.integer "action" | |
25 | - t.integer "author_id" | |
26 | - end | |
27 | - | |
28 | - add_index "events", ["action"], :name => "index_events_on_action" | |
29 | - add_index "events", ["author_id"], :name => "index_events_on_author_id" | |
30 | - add_index "events", ["created_at"], :name => "index_events_on_created_at" | |
31 | - add_index "events", ["project_id"], :name => "index_events_on_project_id" | |
32 | - add_index "events", ["target_id"], :name => "index_events_on_target_id" | |
33 | - add_index "events", ["target_type"], :name => "index_events_on_target_type" | |
34 | - | |
35 | - create_table "issues", :force => true do |t| | |
36 | - t.string "title" | |
37 | - t.integer "assignee_id" | |
38 | - t.integer "author_id" | |
39 | - t.integer "project_id" | |
40 | - t.datetime "created_at", :null => false | |
41 | - t.datetime "updated_at", :null => false | |
42 | - t.integer "position", :default => 0 | |
43 | - t.string "branch_name" | |
44 | - t.text "description" | |
45 | - t.integer "milestone_id" | |
46 | - t.string "state" | |
47 | - end | |
48 | - | |
49 | - add_index "issues", ["assignee_id"], :name => "index_issues_on_assignee_id" | |
50 | - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" | |
51 | - add_index "issues", ["created_at"], :name => "index_issues_on_created_at" | |
52 | - add_index "issues", ["milestone_id"], :name => "index_issues_on_milestone_id" | |
53 | - add_index "issues", ["project_id"], :name => "index_issues_on_project_id" | |
54 | - add_index "issues", ["title"], :name => "index_issues_on_title" | |
55 | - | |
56 | - create_table "keys", :force => true do |t| | |
57 | - t.integer "user_id" | |
58 | - t.datetime "created_at", :null => false | |
59 | - t.datetime "updated_at", :null => false | |
60 | - t.text "key" | |
61 | - t.string "title" | |
62 | - t.string "identifier" | |
63 | - t.integer "project_id" | |
64 | - end | |
65 | - | |
66 | - add_index "keys", ["identifier"], :name => "index_keys_on_identifier" | |
67 | - add_index "keys", ["project_id"], :name => "index_keys_on_project_id" | |
68 | - add_index "keys", ["user_id"], :name => "index_keys_on_user_id" | |
69 | - | |
70 | - create_table "merge_requests", :force => true do |t| | |
71 | - t.string "target_branch", :null => false | |
72 | - t.string "source_branch", :null => false | |
73 | - t.integer "project_id", :null => false | |
74 | - t.integer "author_id" | |
75 | - t.integer "assignee_id" | |
76 | - t.string "title" | |
77 | - t.datetime "created_at", :null => false | |
78 | - t.datetime "updated_at", :null => false | |
79 | - t.text "st_commits", :limit => 2147483647 | |
80 | - t.text "st_diffs", :limit => 2147483647 | |
81 | - t.integer "milestone_id" | |
82 | - t.string "state" | |
83 | - t.string "merge_status" | |
84 | - end | |
85 | - | |
86 | - add_index "merge_requests", ["assignee_id"], :name => "index_merge_requests_on_assignee_id" | |
87 | - add_index "merge_requests", ["author_id"], :name => "index_merge_requests_on_author_id" | |
88 | - add_index "merge_requests", ["created_at"], :name => "index_merge_requests_on_created_at" | |
89 | - add_index "merge_requests", ["milestone_id"], :name => "index_merge_requests_on_milestone_id" | |
90 | - add_index "merge_requests", ["project_id"], :name => "index_merge_requests_on_project_id" | |
91 | - add_index "merge_requests", ["source_branch"], :name => "index_merge_requests_on_source_branch" | |
92 | - add_index "merge_requests", ["target_branch"], :name => "index_merge_requests_on_target_branch" | |
93 | - add_index "merge_requests", ["title"], :name => "index_merge_requests_on_title" | |
94 | - | |
95 | - create_table "milestones", :force => true do |t| | |
96 | - t.string "title", :null => false | |
97 | - t.integer "project_id", :null => false | |
98 | - t.text "description" | |
99 | - t.date "due_date" | |
100 | - t.datetime "created_at", :null => false | |
101 | - t.datetime "updated_at", :null => false | |
102 | - t.string "state" | |
103 | - end | |
104 | - | |
105 | - add_index "milestones", ["due_date"], :name => "index_milestones_on_due_date" | |
106 | - add_index "milestones", ["project_id"], :name => "index_milestones_on_project_id" | |
107 | - | |
108 | - create_table "namespaces", :force => true do |t| | |
109 | - t.string "name", :null => false | |
110 | - t.string "path", :null => false | |
111 | - t.integer "owner_id", :null => false | |
112 | - t.datetime "created_at", :null => false | |
113 | - t.datetime "updated_at", :null => false | |
114 | - t.string "type" | |
115 | - end | |
116 | - | |
117 | - add_index "namespaces", ["name"], :name => "index_namespaces_on_name" | |
118 | - add_index "namespaces", ["owner_id"], :name => "index_namespaces_on_owner_id" | |
119 | - add_index "namespaces", ["path"], :name => "index_namespaces_on_path" | |
120 | - add_index "namespaces", ["type"], :name => "index_namespaces_on_type" | |
121 | - | |
122 | - create_table "notes", :force => true do |t| | |
123 | - t.text "note" | |
124 | - t.string "noteable_type" | |
125 | - t.integer "author_id" | |
126 | - t.datetime "created_at", :null => false | |
127 | - t.datetime "updated_at", :null => false | |
128 | - t.integer "project_id" | |
129 | - t.string "attachment" | |
130 | - t.string "line_code" | |
131 | - t.string "commit_id" | |
132 | - t.integer "noteable_id" | |
133 | - end | |
134 | - | |
135 | - add_index "notes", ["commit_id"], :name => "index_notes_on_commit_id" | |
136 | - add_index "notes", ["created_at"], :name => "index_notes_on_created_at" | |
137 | - add_index "notes", ["noteable_type"], :name => "index_notes_on_noteable_type" | |
138 | - add_index "notes", ["project_id", "noteable_type"], :name => "index_notes_on_project_id_and_noteable_type" | |
139 | - add_index "notes", ["project_id"], :name => "index_notes_on_project_id" | |
140 | - | |
141 | - create_table "projects", :force => true do |t| | |
142 | - t.string "name" | |
143 | - t.string "path" | |
144 | - t.text "description" | |
145 | - t.datetime "created_at", :null => false | |
146 | - t.datetime "updated_at", :null => false | |
147 | - t.integer "creator_id" | |
148 | - t.string "default_branch" | |
149 | - t.boolean "issues_enabled", :default => true, :null => false | |
150 | - t.boolean "wall_enabled", :default => true, :null => false | |
151 | - t.boolean "merge_requests_enabled", :default => true, :null => false | |
152 | - t.boolean "wiki_enabled", :default => true, :null => false | |
153 | - t.integer "namespace_id" | |
154 | - t.boolean "public", :default => false, :null => false | |
155 | - end | |
156 | - | |
157 | - add_index "projects", ["creator_id"], :name => "index_projects_on_owner_id" | |
158 | - add_index "projects", ["namespace_id"], :name => "index_projects_on_namespace_id" | |
159 | - | |
160 | - create_table "protected_branches", :force => true do |t| | |
161 | - t.integer "project_id", :null => false | |
162 | - t.string "name", :null => false | |
163 | - t.datetime "created_at", :null => false | |
164 | - t.datetime "updated_at", :null => false | |
165 | - end | |
166 | - | |
167 | - create_table "services", :force => true do |t| | |
168 | - t.string "type" | |
169 | - t.string "title" | |
170 | - t.string "token" | |
171 | - t.integer "project_id", :null => false | |
172 | - t.datetime "created_at", :null => false | |
173 | - t.datetime "updated_at", :null => false | |
174 | - t.boolean "active", :default => false, :null => false | |
175 | - t.string "project_url" | |
176 | - end | |
177 | - | |
178 | - add_index "services", ["project_id"], :name => "index_services_on_project_id" | |
179 | - | |
180 | - create_table "snippets", :force => true do |t| | |
181 | - t.string "title" | |
182 | - t.text "content" | |
183 | - t.integer "author_id", :null => false | |
184 | - t.integer "project_id", :null => false | |
185 | - t.datetime "created_at", :null => false | |
186 | - t.datetime "updated_at", :null => false | |
187 | - t.string "file_name" | |
188 | - t.datetime "expires_at" | |
189 | - end | |
190 | - | |
191 | - add_index "snippets", ["created_at"], :name => "index_snippets_on_created_at" | |
192 | - add_index "snippets", ["expires_at"], :name => "index_snippets_on_expires_at" | |
193 | - add_index "snippets", ["project_id"], :name => "index_snippets_on_project_id" | |
194 | - | |
195 | - create_table "taggings", :force => true do |t| | |
196 | - t.integer "tag_id" | |
197 | - t.integer "taggable_id" | |
198 | - t.string "taggable_type" | |
199 | - t.integer "tagger_id" | |
200 | - t.string "tagger_type" | |
201 | - t.string "context" | |
202 | - t.datetime "created_at" | |
203 | - end | |
204 | - | |
205 | - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" | |
206 | - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" | |
207 | - | |
208 | - create_table "tags", :force => true do |t| | |
209 | - t.string "name" | |
210 | - end | |
211 | - | |
212 | - create_table "user_team_project_relationships", :force => true do |t| | |
213 | - t.integer "project_id" | |
214 | - t.integer "user_team_id" | |
215 | - t.integer "greatest_access" | |
216 | - t.datetime "created_at", :null => false | |
217 | - t.datetime "updated_at", :null => false | |
218 | - end | |
219 | - | |
220 | - create_table "user_team_user_relationships", :force => true do |t| | |
221 | - t.integer "user_id" | |
222 | - t.integer "user_team_id" | |
223 | - t.boolean "group_admin" | |
224 | - t.integer "permission" | |
225 | - t.datetime "created_at", :null => false | |
226 | - t.datetime "updated_at", :null => false | |
227 | - end | |
228 | - | |
229 | - create_table "user_teams", :force => true do |t| | |
230 | - t.string "name" | |
231 | - t.string "path" | |
232 | - t.integer "owner_id" | |
233 | - t.datetime "created_at", :null => false | |
234 | - t.datetime "updated_at", :null => false | |
235 | - end | |
236 | - | |
237 | - create_table "users", :force => true do |t| | |
238 | - t.string "email", :default => "", :null => false | |
239 | - t.string "encrypted_password", :default => "", :null => false | |
240 | - t.string "reset_password_token" | |
241 | - t.datetime "reset_password_sent_at" | |
242 | - t.datetime "remember_created_at" | |
243 | - t.integer "sign_in_count", :default => 0 | |
244 | - t.datetime "current_sign_in_at" | |
245 | - t.datetime "last_sign_in_at" | |
246 | - t.string "current_sign_in_ip" | |
247 | - t.string "last_sign_in_ip" | |
248 | - t.datetime "created_at", :null => false | |
249 | - t.datetime "updated_at", :null => false | |
250 | - t.string "name" | |
251 | - t.boolean "admin", :default => false, :null => false | |
252 | - t.integer "projects_limit", :default => 10 | |
253 | - t.string "skype", :default => "", :null => false | |
254 | - t.string "linkedin", :default => "", :null => false | |
255 | - t.string "twitter", :default => "", :null => false | |
256 | - t.string "authentication_token" | |
257 | - t.boolean "dark_scheme", :default => false, :null => false | |
258 | - t.integer "theme_id", :default => 1, :null => false | |
259 | - t.string "bio" | |
260 | - t.boolean "blocked", :default => false, :null => false | |
261 | - t.integer "failed_attempts", :default => 0 | |
262 | - t.datetime "locked_at" | |
263 | - t.string "extern_uid" | |
264 | - t.string "provider" | |
265 | - t.string "username" | |
266 | - t.boolean "can_create_group", :default => true, :null => false | |
267 | - t.boolean "can_create_team", :default => true, :null => false | |
268 | - end | |
269 | - | |
270 | - add_index "users", ["admin"], :name => "index_users_on_admin" | |
271 | - add_index "users", ["blocked"], :name => "index_users_on_blocked" | |
272 | - add_index "users", ["email"], :name => "index_users_on_email", :unique => true | |
273 | - add_index "users", ["extern_uid", "provider"], :name => "index_users_on_extern_uid_and_provider", :unique => true | |
274 | - add_index "users", ["name"], :name => "index_users_on_name" | |
275 | - add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true | |
276 | - add_index "users", ["username"], :name => "index_users_on_username" | |
277 | - | |
278 | - create_table "users_projects", :force => true do |t| | |
279 | - t.integer "user_id", :null => false | |
280 | - t.integer "project_id", :null => false | |
281 | - t.datetime "created_at", :null => false | |
282 | - t.datetime "updated_at", :null => false | |
283 | - t.integer "project_access", :default => 0, :null => false | |
284 | - end | |
285 | - | |
286 | - add_index "users_projects", ["project_access"], :name => "index_users_projects_on_project_access" | |
287 | - add_index "users_projects", ["project_id"], :name => "index_users_projects_on_project_id" | |
288 | - add_index "users_projects", ["user_id"], :name => "index_users_projects_on_user_id" | |
289 | - | |
290 | - create_table "web_hooks", :force => true do |t| | |
291 | - t.string "url" | |
292 | - t.integer "project_id" | |
293 | - t.datetime "created_at", :null => false | |
294 | - t.datetime "updated_at", :null => false | |
295 | - t.string "type", :default => "ProjectHook" | |
296 | - t.integer "service_id" | |
297 | - end | |
298 | - | |
299 | - create_table "wikis", :force => true do |t| | |
300 | - t.string "title" | |
301 | - t.text "content" | |
302 | - t.integer "project_id" | |
303 | - t.datetime "created_at", :null => false | |
304 | - t.datetime "updated_at", :null => false | |
305 | - t.string "slug" | |
306 | - t.integer "user_id" | |
307 | - end | |
308 | - | |
309 | - add_index "wikis", ["project_id"], :name => "index_wikis_on_project_id" | |
310 | - add_index "wikis", ["slug"], :name => "index_wikis_on_slug" | |
311 | - | |
312 | -end |
lib/gitlab/markdown.rb
... | ... | @@ -163,8 +163,11 @@ module Gitlab |
163 | 163 | end |
164 | 164 | |
165 | 165 | def reference_issue(identifier) |
166 | - if issue = @project.issues.where(id: identifier).first | |
167 | - link_to("##{identifier}", project_issue_url(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) | |
166 | + if issue_exists? identifier | |
167 | + url = url_for_issue(identifier) | |
168 | + title = title_for_issue(identifier) | |
169 | + | |
170 | + link_to("##{identifier}", url, html_options.merge(title: "Issue: #{title}", class: "gfm gfm-issue #{html_options[:class]}")) | |
168 | 171 | end |
169 | 172 | end |
170 | 173 | ... | ... |
spec/helpers/gitlab_markdown_helper_spec.rb
... | ... | @@ -0,0 +1,16 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe IssuesTracker do | |
4 | + let(:project) { double('project') } | |
5 | + | |
6 | + before do | |
7 | + @project = project | |
8 | + project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0'])) | |
9 | + project.stub(path_with_namespace: 'gitlab/gitlab-ci') | |
10 | + end | |
11 | + | |
12 | + it 'returns url for issue' do | |
13 | + ololo | |
14 | + end | |
15 | +end | |
16 | + | ... | ... |