Commit 1101ceb3 authored by Hiroyuki Sato's avatar Hiroyuki Sato

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.
parent 5f24bdb7
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.pull-left .pull-left
= form_tag project_network_path(@project, @id), method: :get do |f| = form_tag project_network_path(@project, @id), method: :get do |f|
.control-group .control-group
= label_tag :filter_ref, "Show only selected ref", class: 'control-label light' = label_tag :filter_ref, "Begin with the selected commit", class: 'control-label light'
.controls .controls
= check_box_tag :filter_ref, 1, @options[:filter_ref] = check_box_tag :filter_ref, 1, @options[:filter_ref]
- @options.each do |key, value| - @options.each do |key, value|
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
.control-group .control-group
= label_tag :search , "Looking for commit:", class: 'control-label light' = label_tag :search , "Looking for commit:", class: 'control-label light'
.controls .controls
= text_field_tag :q, @options[:q], placeholder: "Input SHA", class: "search-input input-xlarge" = text_field_tag :extended_sha1, @options[:extended_sha1], placeholder: "Input an extended SHA1 syntax", class: "search-input input-xlarge"
= button_tag type: 'submit', class: 'btn vtop' do = button_tag type: 'submit', class: 'btn vtop' do
%i.icon-search %i.icon-search
- @options.each do |key, value| - @options.each do |key, value|
= hidden_field_tag(key, value, id: nil) unless key == "q" = hidden_field_tag(key, value, id: nil) unless key == "extended_sha1"
...@@ -76,7 +76,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -76,7 +76,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
When 'I looking for a commit by SHA of "v2.1.0"' do When 'I looking for a commit by SHA of "v2.1.0"' do
within ".content .search" do within ".content .search" do
fill_in 'q', with: '98d6492' fill_in 'extended_sha1', with: '98d6492'
find('button').click find('button').click
end end
sleep 2 sleep 2
...@@ -90,7 +90,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -90,7 +90,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
When 'I look for a commit by ";"' do When 'I look for a commit by ";"' do
within ".content .search" do within ".content .search" do
fill_in 'q', with: ';' fill_in 'extended_sha1', with: ';'
find('button').click find('button').click
end end
end end
......
...@@ -95,17 +95,17 @@ module ExtractsPath ...@@ -95,17 +95,17 @@ module ExtractsPath
# resolved (e.g., when a user inserts an invalid path or ref). # resolved (e.g., when a user inserts an invalid path or ref).
def assign_ref_vars def assign_ref_vars
# assign allowed options # assign allowed options
allowed_options = ["filter_ref", "q"] allowed_options = ["filter_ref", "extended_sha1"]
@options = params.select {|key, value| allowed_options.include?(key) && !value.blank? } @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
@options = HashWithIndifferentAccess.new(@options) @options = HashWithIndifferentAccess.new(@options)
@id = get_id @id = get_id
@ref, @path = extract_ref(@id) @ref, @path = extract_ref(@id)
@repo = @project.repository @repo = @project.repository
if @options[:q].blank? if @options[:extended_sha1].blank?
@commit = @repo.commit(@ref) @commit = @repo.commit(@ref)
else else
@commit = @repo.commit(@options[:q]) @commit = @repo.commit(@options[:extended_sha1])
end end
@tree = Tree.new(@repo, @commit.id, @ref, @path) @tree = Tree.new(@repo, @commit.id, @ref, @path)
@hex_path = Digest::SHA1.hexdigest(@path) @hex_path = Digest::SHA1.hexdigest(@path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment