LivelyKernel/js-git-browser

invalid date issue with github mixin

musicog opened this issue · 0 comments

When invoking repo.saveAs for a new commit using the github mixin, the date value handed to the author object (and supplied to encodePerson and ultimately encodeDate in jsgit.js) is expected to be an object with fields like "offset" and "seconds", but is actually a Javascript Date object. This causes "invalid date" errors to be thrown by encodeDate and prevents commits from being written to GitHub.

I've "fixed" this for my own GitHub-centric use-case by simply hacking encodePerson to use the Date object's toISOString(), bypassing encodeDate -- see the small change in my fork here:

https://github.com/musicog/js-git-browser/blob/fix-date-issue/jsgit.js#L10005

However I appreciate this might well break non-GitHub-centric use-cases. Perhaps you have an idea of how to fix this properly?

Many thanks for the helpful module!