summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-08-02 19:24:34 +0000
committerFatih Acet <acetfatih@gmail.com>2016-08-02 19:24:34 +0000
commit90c277aa3cd55322d1bfe68ce8e9dd38c1a5c347 (patch)
tree46e16c64c2b07d49d3f25a75818baea499e82f3d
parentb5eb94ea0ca740bef801cc31870bc753d32924eb (diff)
parente4c517a635b6a45a9afc65b37682cc4b4951e922 (diff)
downloadgitlab-ce-90c277aa3cd55322d1bfe68ce8e9dd38c1a5c347.tar.gz
Merge branch 'expand-commit-message-view' into 'master'
Expand commit message width in repo view ## What does this MR do? Expands the commit message width in repo view to take advantage of the unused white space (under the history href) ## Are there points in the code the reviewer needs to double check? Just need to make sure there aren't any side effects ## Why was this MR needed? To take advantage of the unused space on repo views ## What are the relevant issue numbers? Closes #20225 ## Screenshots Before: ![Screen_Shot_2016-07-27_at_11.10.22_AM](/uploads/1f2c604ac6d4ede2bac67179cfe77b20/Screen_Shot_2016-07-27_at_11.10.22_AM.png) After: ![Screen_Shot_2016-07-27_at_11.08.55_AM](/uploads/34a36c884a06fd6cfd9b6512d1230196/Screen_Shot_2016-07-27_at_11.08.55_AM.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] Added tests - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5494
-rw-r--r--CHANGELOG1
-rw-r--r--app/assets/stylesheets/pages/tree.scss4
-rw-r--r--app/models/commit.rb14
-rw-r--r--app/views/projects/tree/_tree_commit_column.html.haml2
-rw-r--r--spec/models/commit_spec.rb21
5 files changed, 35 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 963fec597d5..b44627a9a71 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@ v 8.11.0 (unreleased)
- Fix CI status icon link underline (ClemMakesApps)
- The Repository class is now instrumented
- Cache the commit author in RequestStore to avoid extra lookups in PostReceive
+ - Expand commit message width in repo view (ClemMakesApps)
- Fix of 'Commits being passed to custom hooks are already reachable when using the UI'
- Add support for using RequestStore within Sidekiq tasks via SIDEKIQ_REQUEST_STORE env variable
- Optimize maximum user access level lookup in loading of notes
diff --git a/app/assets/stylesheets/pages/tree.scss b/app/assets/stylesheets/pages/tree.scss
index 390977297fb..9da40fe2b09 100644
--- a/app/assets/stylesheets/pages/tree.scss
+++ b/app/assets/stylesheets/pages/tree.scss
@@ -58,6 +58,10 @@
.tree_commit {
max-width: 320px;
+
+ .str-truncated {
+ max-width: 100%;
+ }
}
.tree_time_ago {
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 486ad6714d9..c52b4a051c2 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -123,15 +123,17 @@ class Commit
# In case this first line is longer than 100 characters, it is cut off
# after 80 characters and ellipses (`&hellp;`) are appended.
def title
- title = safe_message
+ full_title.length > 100 ? full_title[0..79] << "…" : full_title
+ end
- return no_commit_message if title.blank?
+ # Returns the full commits title
+ def full_title
+ return @full_title if @full_title
- title_end = title.index("\n")
- if (!title_end && title.length > 100) || (title_end && title_end > 100)
- title[0..79] << "…"
+ if safe_message.blank?
+ @full_title = no_commit_message
else
- title.split("\n", 2).first
+ @full_title = safe_message.split("\n", 2).first
end
end
diff --git a/app/views/projects/tree/_tree_commit_column.html.haml b/app/views/projects/tree/_tree_commit_column.html.haml
index a3a4bd4f752..84da16b6bb1 100644
--- a/app/views/projects/tree/_tree_commit_column.html.haml
+++ b/app/views/projects/tree/_tree_commit_column.html.haml
@@ -1,2 +1,2 @@
%span.str-truncated
- = link_to_gfm commit.title, namespace_project_commit_path(@project.namespace, @project, commit.id), class: "tree-commit-link"
+ = link_to_gfm commit.full_title, namespace_project_commit_path(@project.namespace, @project, commit.id), class: "tree-commit-link"
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index c3392ee7440..d3e6a6648cc 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -86,6 +86,27 @@ eos
end
end
+ describe '#full_title' do
+ it "returns no_commit_message when safe_message is blank" do
+ allow(commit).to receive(:safe_message).and_return('')
+ expect(commit.full_title).to eq("--no commit message")
+ end
+
+ it "returns entire message if there is no newline" do
+ message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
+
+ allow(commit).to receive(:safe_message).and_return(message)
+ expect(commit.full_title).to eq(message)
+ end
+
+ it "returns first line of message if there is a newLine" do
+ message = commit.safe_message.split(" ").first
+
+ allow(commit).to receive(:safe_message).and_return(message + "\n" + message)
+ expect(commit.full_title).to eq(message)
+ end
+ end
+
describe "delegation" do
subject { commit }