rtyley/bfg-repo-cleaner — pull request #54 by choffmeister (2014-09-18 22:30:22+00:00)
Title: Timestamp modification via curfews

We all have done it at least once: Sometimes you make a commit when you should do something else. Afterwards when you want to publish your commits (maybe on an open source project) the commit timestamps reveal your sin.

Here the CommitTimestampCurfewShifter (the name kind of sucks, maybe someone has a better idea): You can pass it an `Date => Boolean` that indicates for any timestamp if it represents a time where you where allowed to work on a project. For example

~~~ scala
import java.util.Date

(t: Date) => !(t.getDay >= 1 && t.getDay <= 5 && t.getHours >= 8 && t.getHours < 18)
~~~

Yields `false` on working days between 6 and 18 o'clock and `true` else. This `CommitNodeCleaner` shifts all commit timestamps like so:

~~~
original A B C D E
| | | | |
shifted a | | b | c d | | E
| | | | | | | | | |
----------------#############-----------------------------#############-----------> time
allowed forbidden allowed forbidden
~~~

It already works pretty well. But there is one problem: This action is not idempotent yet. Is there any way to look over all commits in advance and clean the commits afterwards? My idea would be, if all commits between two forbidden times are in the allowed time phase, then none of the commits has to be shifted. If a single commit is in the forbidden phase, the all commits in the same group have to be shifted (to keep the ratios between the single commits).

What do you think? I know this still needs some elaboration and is not ready to be merged, but I wanted to share the idea.

Btw: I would choose "Assign the copyright on the contribution to myself, Roberto Tyley" in case this should make into the repo.