summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-13 21:20:03 +0200
committerZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-13 21:28:59 +0200
commit36da31d1fe722fa74ead0ba9977ef054009ea6c7 (patch)
tree7901d1fdcc91c6a7477bbd55c5d7cc116a52aa3e
parentc0678f2d281242601560e2646cab1aa8a349c4bb (diff)
downloadgitlab-ce-start-with-iid-on-new-branch.tar.gz
Start with iid on branch creationstart-with-iid-on-new-branch
-rw-r--r--app/models/issue.rb8
-rw-r--r--app/services/merge_requests/build_service.rb2
-rw-r--r--app/services/system_note_service.rb2
-rw-r--r--doc/workflow/web_editor.md2
-rw-r--r--spec/models/issue_spec.rb6
5 files changed, 10 insertions, 10 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index e064b0f8b95..f314767f94d 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -105,10 +105,10 @@ class Issue < ActiveRecord::Base
end
def related_branches
- project.repository.branch_names.select do |branch|
- branch.end_with?("-#{iid}")
+ self.project.repository.branch_names.select do |branch|
+ branch =~ /\A#{iid}-(?!\d+-stable)/i
end
- end
+ end
# Reset issue events cache
#
@@ -151,7 +151,7 @@ class Issue < ActiveRecord::Base
end
def to_branch_name
- "#{title.parameterize}-#{iid}"
+ "#{iid}-#{title.parameterize}"
end
def can_be_worked_on?(current_user)
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb
index 6e9152e444e..fa34753c4fd 100644
--- a/app/services/merge_requests/build_service.rb
+++ b/app/services/merge_requests/build_service.rb
@@ -51,7 +51,7 @@ module MergeRequests
# be interpreted as the use wants to close that issue on this project
# Pattern example: 112-fix-mep-mep
# Will lead to appending `Closes #112` to the description
- if match = merge_request.source_branch.match(/-(\d+)\z/)
+ if match = merge_request.source_branch.match(/\A(\d+)-/)
iid = match[1]
closes_issue = "Closes ##{iid}"
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index 658b086496f..82a0e2fd1f5 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -222,7 +222,7 @@ class SystemNoteService
# Called when a branch is created from the 'new branch' button on a issue
# Example note text:
#
- # "Started branch `issue-branch-button-201`"
+ # "Started branch `201-issue-branch-button`"
def self.new_issue_branch(issue, project, author, branch)
h = Gitlab::Routing.url_helpers
link = h.namespace_project_compare_url(project.namespace, project, from: project.default_branch, to: branch)
diff --git a/doc/workflow/web_editor.md b/doc/workflow/web_editor.md
index 5685a9d89dd..1832567a34c 100644
--- a/doc/workflow/web_editor.md
+++ b/doc/workflow/web_editor.md
@@ -85,7 +85,7 @@ Once you click it, a new branch will be created that diverges from the default
branch of your project, by default `master`. The branch name will be based on
the title of the issue and as suffix it will have its ID. Thus, the example
screenshot above will yield a branch named
-`et-cum-et-sed-expedita-repellat-consequatur-ut-assumenda-numquam-rerum-2`.
+`2-et-cum-et-sed-expedita-repellat-consequatur-ut-assumenda-numquam-rerum`.
After the branch is created, you can edit files in the repository to fix
the issue. When a merge request is created based on the newly created branch,
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 15052aaca28..3e12816627f 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -210,11 +210,11 @@ describe Issue, models: true do
let(:subject) { create :issue }
end
- describe "#to_branch_name" do
+ describe '#to_branch_name' do
let(:issue) { create(:issue, title: 'a' * 30) }
- it "starts with the issue iid" do
- expect(issue.to_branch_name).to match /-#{issue.iid}\z/
+ it 'starts with the issue iid' do
+ expect(issue.to_branch_name).to match /\A#{issue.iid}-a+\z/
end
end
end