New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collapse tags with same slug #1029
Conversation
if tag not in self.posts_per_tag: | ||
# Tags that differ only in case | ||
other_tag = [k for k in self.posts_per_tag.keys() if k.lower() == tag.lower()][0] | ||
utils.LOGGER.error('You have cases that differ only in upper/lower case: {0} and {1}'.format(tag, other_tag)) | ||
utils.LOGGER.error('You have tags that are too similar: {0} and {1}'.format(tag, other_tag)) | ||
utils.LOGGER.error('Tag {0} is used in: {1}'.format(tag, post.source_path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make it so we show all the posts that have the tag? Like this:
- keep a list of conflicts internally
- while done, show it at once and exit
Also, how does this work with 3-way conflicts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, reporting them all at once is a bit harder. I could make it continue so it reports them all and then fail on the repeated target error tho.
3-way conflicts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3-way conflicts, as in:
>>> map(nikola.utils.slugify, [u'foo.bar', u'foo,bar', u'foobar'])
['foobar', 'foobar', 'foobar']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove the exit, you get this:
Scanning posts.[2014-02-05T19:40:28Z] ERROR: Nikola: You have tags that are too similar: foo and fOo
[2014-02-05T19:40:28Z] ERROR: Nikola: Tag foo is used in: posts/foo.rst
[2014-02-05T19:40:28Z] ERROR: Nikola: Tag fOo is used in: posts/foo.rst
[2014-02-05T19:40:28Z] ERROR: Nikola: You have tags that are too similar: Foo and fOo
[2014-02-05T19:40:28Z] ERROR: Nikola: Tag Foo is used in: posts/foo.rst
[2014-02-05T19:40:28Z] ERROR: Nikola: Tag fOo is used in: posts/foo.rst
...done!
ERROR: Task generation 'render_site' has duplicated definition of 'render_tags:output/categories/foo.xml'
That's not horrible ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though if you want that ugly doit ERROR dead:
utils.LOGGER.error('Tag {0} is used in: {1}'.format(other_tag, ', '.join(self.posts_per_tag[other_tag])))
+quit = 1
⋮
+if quit:
+ sys.exit(1)
(define quit = 0
earlier)
Fix #1022 by declaring that two tags that generate the same slug is an error.