gjtorikian / jekyll-last-modified-at

A Jekyll plugin to show the last_modified_at time of a post.
MIT License
243 stars 39 forks source link

Inconsistent results when running inside a Travis container #46

Closed ilg-ul closed 7 years ago

ilg-ul commented 7 years ago

Hi,

I used the plug-in successfully, until yesterday, when I moved the build to Travis (https://travis-ci.org/gnuarmeclipse/gnuarmeclipse.github.io-source).

My pages (and my posts) have a 'Last modified on' timestamp, implemented like:

<p class="page-footer">Last modified on {{ page.last_modified_at | date: '%c %Z' }}.</p>

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/_layouts/page.html

For example the pages/about.md is dated Oct 3, 2015, and all pages generated before the move to Travis looked ok.

After the move, with each Travis run, these values change to strange dates from 2016:

-<p class="page-footer">Last modified on Sat Oct  3 17:33:27 2015 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:27:16 2016 UTC.</p>

(from commit https://github.com/gnuarmeclipse/gnuarmeclipse.github.io/commit/bfaed6329f960be5e13b249bfbacd3118d8485f1#diff-a7224db13f3a49096aa27c1876d1a947)

-<p class="page-footer">Last modified on Fri Oct 28 17:27:16 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:29:18 2016 UTC.</p>

(from commit https://github.com/gnuarmeclipse/gnuarmeclipse.github.io/commit/d2b296c0aaf465ab2783f0a244f1478ec7913e86#diff-a7224db13f3a49096aa27c1876d1a947)

-<p class="page-footer">Last modified on Fri Oct 28 17:29:18 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 17:29:57 2016 UTC.</p>

(from commit https://github.com/gnuarmeclipse/gnuarmeclipse.github.io/commit/55e15dffb829ab3ad20cc1f596ff7f90d56922ff#diff-a7224db13f3a49096aa27c1876d1a947)

and so on, to the last commit

-<p class="page-footer">Last modified on Fri Oct 28 18:07:56 2016 UTC.</p>
+<p class="page-footer">Last modified on Fri Oct 28 18:08:47 2016 UTC.</p>

(from commit https://github.com/gnuarmeclipse/gnuarmeclipse.github.io/commit/5fb489e6802c264dd5fb66fbbcc509999e7d0a48#diff-a7224db13f3a49096aa27c1876d1a947)

I have no idea where these wrong dates come from.

The Travis script is apparently benign, it runs jekyll via bundle:

cd "${slug}"
bundle exec jekyll build --destination "${site}"

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/scripts/travis.linux.sh

The Gemfile explicitly asks for 1.0.0

jekyll-last-modified-at (>= 1.0.0)

and the Gemfile.lock` confirms this:

    jekyll-last-modified-at (1.0.0)
      jekyll (~> 3.2.1)
      posix-spawn (~> 0.3.9)

https://github.com/gnuarmeclipse/gnuarmeclipse.github.io-source/blob/master/Gemfile.lock

Any suggestion on what can be so wrong?

Unfortunately this problem prevents me to continue use Travis, and forces me to revert to manual local builds. :-(

ilg-ul commented 7 years ago

I changed the travis script to display the differences from the current manually built site, and now I can see the proposed modified date for each run.

for example:

https://travis-ci.org/gnuarmeclipse/gnuarmeclipse.github.io-source/builds/198959960

as you can see, in this run the plug-in returned the same date for all files:

+<p class="page-footer">Last modified on Tue Nov 29 08:47:10 2016 UTC.</p>

I cannot match this timestamp with any commit in the repository, I have no idea where this might come from.

ilg-ul commented 7 years ago

After a long debugging session, I discovered that Travis clones only the last 50 commits, so, for larger repositories, the committer date is no longer available, and the oldest commit date is displayed, which explains why all posts were stamped with the same date.

Conclusion: the reported problem is not related to the plug-in, but to incorrect usage of an incomplete repository.

Suggestion: explicitly mention in the documentation that incomplete repositories cannot be used; if possible, test if the repository is incomplete, and fail.