Commit 1101ceb3f4dfb8983f5876215378331a2d9bcc88

Authored by Hiroyuki Sato
1 parent 5f24bdb7

A little improvement

1. Replace params key 'q' with 'extended_sha1'. A extended SHA1 syntax is explained in 'man gitrevisions'.
2. Change the placeholder of looking for commit.
3. Change the label of ref filter.
app/views/projects/network/_head.html.haml
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 .pull-left 4 .pull-left
5 = form_tag project_network_path(@project, @id), method: :get do |f| 5 = form_tag project_network_path(@project, @id), method: :get do |f|
6 .control-group 6 .control-group
7 - = label_tag :filter_ref, "Show only selected ref", class: 'control-label light' 7 + = label_tag :filter_ref, "Begin with the selected commit", class: 'control-label light'
8 .controls 8 .controls
9 = check_box_tag :filter_ref, 1, @options[:filter_ref] 9 = check_box_tag :filter_ref, 1, @options[:filter_ref]
10 - @options.each do |key, value| 10 - @options.each do |key, value|
@@ -15,9 +15,9 @@ @@ -15,9 +15,9 @@
15 .control-group 15 .control-group
16 = label_tag :search , "Looking for commit:", class: 'control-label light' 16 = label_tag :search , "Looking for commit:", class: 'control-label light'
17 .controls 17 .controls
18 - = text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input input-xlarge" 18 + = text_field_tag :extended_sha1, @options[:extended_sha1], placeholder: "Input an extended SHA1 syntax", class: "search-input input-xlarge"
19 = button_tag type: 'submit', class: 'btn vtop' do 19 = button_tag type: 'submit', class: 'btn vtop' do
20 %i.icon-search 20 %i.icon-search
21 - @options.each do |key, value| 21 - @options.each do |key, value|
22 - = hidden_field_tag(key, value, id: nil) unless key == "q" 22 + = hidden_field_tag(key, value, id: nil) unless key == "extended_sha1"
23 23
features/steps/project/project_network_graph.rb
@@ -76,7 +76,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps @@ -76,7 +76,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
76 76
77 When 'I looking for a commit by SHA of "v2.1.0"' do 77 When 'I looking for a commit by SHA of "v2.1.0"' do
78 within ".content .search" do 78 within ".content .search" do
79 - fill_in 'q', with: '98d6492' 79 + fill_in 'extended_sha1', with: '98d6492'
80 find('button').click 80 find('button').click
81 end 81 end
82 sleep 2 82 sleep 2
@@ -90,7 +90,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps @@ -90,7 +90,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
90 90
91 When 'I look for a commit by ";"' do 91 When 'I look for a commit by ";"' do
92 within ".content .search" do 92 within ".content .search" do
93 - fill_in 'q', with: ';' 93 + fill_in 'extended_sha1', with: ';'
94 find('button').click 94 find('button').click
95 end 95 end
96 end 96 end
lib/extracts_path.rb
@@ -95,17 +95,17 @@ module ExtractsPath @@ -95,17 +95,17 @@ module ExtractsPath
95 # resolved (e.g., when a user inserts an invalid path or ref). 95 # resolved (e.g., when a user inserts an invalid path or ref).
96 def assign_ref_vars 96 def assign_ref_vars
97 # assign allowed options 97 # assign allowed options
98 - allowed_options = ["filter_ref", "q"] 98 + allowed_options = ["filter_ref", "extended_sha1"]
99 @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } 99 @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
100 @options = HashWithIndifferentAccess.new(@options) 100 @options = HashWithIndifferentAccess.new(@options)
101 101
102 @id = get_id 102 @id = get_id
103 @ref, @path = extract_ref(@id) 103 @ref, @path = extract_ref(@id)
104 @repo = @project.repository 104 @repo = @project.repository
105 - if @options[:q].blank? 105 + if @options[:extended_sha1].blank?
106 @commit = @repo.commit(@ref) 106 @commit = @repo.commit(@ref)
107 else 107 else
108 - @commit = @repo.commit(@options[:q]) 108 + @commit = @repo.commit(@options[:extended_sha1])
109 end 109 end
110 @tree = Tree.new(@repo, @commit.id, @ref, @path) 110 @tree = Tree.new(@repo, @commit.id, @ref, @path)
111 @hex_path = Digest::SHA1.hexdigest(@path) 111 @hex_path = Digest::SHA1.hexdigest(@path)