Compare commits

...

6 Commits

Author SHA1 Message Date
Parker Moore
d842f02b20 Release 💎 3.0.2 2016-01-20 14:14:22 -08:00
Parker Moore
3dfc0f26e1 We can release from 3.0-stable 2016-01-20 14:14:15 -08:00
Parker Moore
8e27409029 Merge branch '3.0-stable' of github.com:jekyll/jekyll into 3.0-stable
* '3.0-stable' of github.com:jekyll/jekyll:
  Document: throw a useful error when an invalid date is given
2016-01-20 14:10:57 -08:00
Parker Moore
766149cd83 Release 💎 v3.0.2 2016-01-20 14:10:47 -08:00
Parker Moore
f4523cb897 Merge pull request #4378 from jekyll/invalid-date-error
Document: throw a useful error when an invalid date is given
2016-01-20 14:07:22 -08:00
Parker Moore
805b117238 Document: throw a useful error when an invalid date is given 2016-01-20 12:23:48 -08:00
8 changed files with 65 additions and 14 deletions

View File

@@ -1,4 +1,8 @@
## HEAD
## 3.0.2 / 2016-01-20
### Bug Fixes
* Document: throw a useful error when an invalid date is given (#4378)
### Development Fixes

View File

@@ -288,8 +288,8 @@ end
desc "Release #{name} v#{version}"
task :release => :build do
unless `git branch` =~ /^\* master$/
puts "You must be on the master branch to release!"
unless `git branch` =~ /^\* 3\.0-stable$/
puts "You must be on the 3.0-stable branch to release!"
exit!
end
sh "git commit --allow-empty -m 'Release :gem: #{version}'"

View File

@@ -36,6 +36,20 @@ Feature: Post data
Then the _site directory should exist
And I should see "Post date: 27 Mar 2009" in "_site/2009/03/27/star-wars.html"
Scenario: Use post.date variable with invalid
Given I have a _posts directory
And I have a "_posts/2016-01-01-test.md" page with date "tuesday" that contains "I have a bad date."
When I run jekyll build
Then the _site directory should not exist
And I should see "Document '_posts/2016-01-01-test.md' does not have a valid date in the YAML front matter." in the build output
Scenario: Invalid date in filename
Given I have a _posts directory
And I have a "_posts/2016-22-01-test.md" page that contains "I have a bad date."
When I run jekyll build
Then the _site directory should not exist
And I should see "Document '_posts/2016-22-01-test.md' does not have a valid date in the filename." in the build output
Scenario: Use post.id variable
Given I have a _posts directory
And I have a _layouts directory

View File

@@ -58,7 +58,7 @@ module Jekyll
# Merge some data in with this document's data.
#
# Returns the merged data.
def merge_data!(other)
def merge_data!(other, source: "YAML front matter")
if other.key?('categories') && !other['categories'].nil?
if other['categories'].is_a?(String)
other['categories'] = other['categories'].split(" ").map(&:strip)
@@ -67,7 +67,7 @@ module Jekyll
end
Utils.deep_merge_hashes!(data, other)
if data.key?('date') && !data['date'].is_a?(Time)
data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the YAML front matter.")
data['date'] = Utils.parse_date(data['date'].to_s, "Document '#{relative_path}' does not have a valid date in the #{source}.")
end
data
end
@@ -287,20 +287,23 @@ module Jekyll
else
begin
defaults = @site.frontmatter_defaults.all(url, collection.label.to_sym)
merge_data!(defaults) unless defaults.empty?
merge_data!(defaults, source: "front matter defaults") unless defaults.empty?
self.content = File.read(path, merged_file_read_opts(opts))
if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH
data_file = SafeYAML.load($1)
merge_data!(data_file) if data_file
merge_data!(data_file, source: "YAML front matter") if data_file
end
post_read
rescue SyntaxError => e
puts "YAML Exception reading #{path}: #{e.message}"
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{e.message}"
rescue Exception => e
puts "Error reading file #{path}: #{e.message}"
if e.is_a? Jekyll::Errors::FatalException
raise e
end
Jekyll.logger.error "Error:", "could not read file #{path}: #{e.message}"
end
end
end
@@ -311,8 +314,10 @@ module Jekyll
merge_data!({
"slug" => slug,
"ext" => ext
})
merge_data!({"date" => date}) if data['date'].nil? || data['date'].to_i == site.time.to_i
}, source: "filename")
if data['date'].nil? || data['date'].to_i == site.time.to_i
merge_data!({"date" => date}, source: "filename")
end
data['title'] ||= slug.split('-').select {|w| w.capitalize! || w }.join(' ')
end
populate_categories
@@ -332,7 +337,7 @@ module Jekyll
superdirs = relative_path.sub(/#{special_dir}(.*)/, '').split(File::SEPARATOR).reject do |c|
c.empty? || c.eql?(special_dir) || c.eql?(basename)
end
merge_data!({ 'categories' => superdirs })
merge_data!({ 'categories' => superdirs }, source: "file path")
end
def populate_categories

View File

@@ -224,7 +224,7 @@ module Jekyll
# Build a hash map based on the specified post attribute ( post attr =>
# array of posts ) then sort each array in reverse order.
hash = Hash.new { |h, key| h[key] = [] }
posts.docs.each { |p| p.data[post_attr].each { |t| hash[t] << p } }
posts.docs.each { |p| p.data[post_attr].each { |t| hash[t] << p } if p.data[post_attr] }
hash.values.each { |posts| posts.sort!.reverse! }
hash
end

View File

@@ -1,3 +1,3 @@
module Jekyll
VERSION = '3.0.1'
VERSION = '3.0.2'
end

View File

@@ -4,6 +4,20 @@ title: History
permalink: "/docs/history/"
---
## 3.0.2 / 2016-01-20
{: #v3-0-2}
### Bug Fixes
{: #bug-fixes-v3-0-2}
- Document: throw a useful error when an invalid date is given ([#4378]({{ site.repository }}/issues/4378))
### Development Fixes
{: #development-fixes-v3-0-2}
- `jekyll-docs` should be easily release-able ([#4152]({{ site.repository }}/issues/4152))
## 3.0.1 / 2015-11-17
{: #v3-0-1}

View File

@@ -0,0 +1,14 @@
---
layout: news_item
title: 'Jekyll 3.0.2 Released'
date: 2016-01-20 14:08:18 -0800
author: parkr
version: 3.0.2
categories: [release]
---
A crucial bug was found in v3.0.1 which caused invalid post dates to go
unnoticed in the build chain until the error that popped up was unhelpful.
v3.0.2 [throws errors as you'd expect](https://github.com/jekyll/jekyll/issues/4375)
when there is a post like `_posts/2016-22-01-future.md` or a post has an
invalid date like `date: "tuesday"` in their front matter.