Skip to content

Commit 0b15142

Browse files
committed
Improve messaging for NoDuplicateTags
1 parent 9b8b673 commit 0b15142

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/jekyll-pre-commit/checks/no_duplicate_tags.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def check(staged, not_staged, site, args)
1414

1515
n = Jekyll::Utils.slugify(tag)
1616
if !normalized[n]
17-
normalized[n] = post.relative_path
17+
normalized[n] = Hash.new
18+
normalized[n]["path"] = post.relative_path
19+
normalized[n]["tag"] = tag
1820
end
1921
end
2022
end
@@ -27,7 +29,7 @@ def check(staged, not_staged, site, args)
2729

2830
if normalized[n] && !raw[tag]
2931
@result[:ok] = false
30-
@result[:message] += "#{tag} appears to be duplicated in #{normalized[n]}!"
32+
@result[:message] += "The tag '#{tag}' appears to be duplicated and is listed as '#{normalized[n]["tag"]}' in #{normalized[n]["path"]}. "
3133
end
3234
end
3335
end

spec/jekyll-pre-commit_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
it "fails if a staged post has duplicate tags" do
202202
result = runner.run(site, ["spec/fixtures/_posts/2017-07-24-duplicate-tags-2.md"])
203203
expect(result[:ok]).to eql(false)
204-
expect(result[:messages]).to match_array(["duplicate appears to be duplicated in _posts/2017-07-24-duplicate-tags-1.md!"])
204+
expect(result[:messages]).to match_array(["The tag 'duplicate' appears to be duplicated and is listed as 'Duplicate' in _posts/2017-07-24-duplicate-tags-1.md. "])
205205
end
206206
end
207207

0 commit comments

Comments
 (0)