Skip to content

Commit time bug(s) #10

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

Closed
bagby opened this issue May 12, 2011 · 2 comments
Closed

Commit time bug(s) #10

bagby opened this issue May 12, 2011 · 2 comments
Assignees
Labels
Milestone

Comments

@bagby
Copy link

bagby commented May 12, 2011

Sorry I can't commit code from work, otherwise I would :-(

There seem to be 2 issues.

  1. Commit time should be converted from int to long before conversion to Date (lines 253-256):
  int timeSinceEpoch = headCommit.getCommitTime();
  Date commitDate = new Date(timeSinceEpoch * 1000); // git is "by sec" and java is "by ms"
  SimpleDateFormat smf = new SimpleDateFormat(dateFormat);
  put(properties, prefixDot + COMMIT_TIME, smf.format(commitDate));

Since timeSinceEpoch is something like 1305045215, multiplying by 1000 exceeds MAX_INT and makes it negative. Line 253 should be something like:

long timeSinceEpoch = new Integer(headCommit.getCommitTime()).longValue();
  1. loadBuildTimeData() is overwriting the same property that the above code is setting (lines 191-193):
Date commitDate = new Date();
SimpleDateFormat smf = new SimpleDateFormat(dateFormat);
put(properties, prefixDot + COMMIT_TIME, smf.format(commitDate)); 

Create a new const BUILD_TIME, and use that instead.

The effect of both of these is that ${git.commit.time} actually gives me the build time, which in my case is not the end of the world (it's "close enough"), but it could be very misleading.

@ktoso
Copy link
Collaborator

ktoso commented May 14, 2011

Hi and thanks a lot for your contribution!
I'll look right into it (when I come home) - we're at the geecon.org hackergarten right now, so it's great we'd be able to fix yet another bug during this day :-)

@ghost ghost assigned ktoso May 15, 2011
@ktoso
Copy link
Collaborator

ktoso commented May 15, 2011

Both issues resolved, thank you very much for pointing them out! 👍

Will now release 1.4 stable to sonatype repository, please update your pomfile to use the new version.

@ktoso ktoso closed this as completed May 15, 2011
ktoso added a commit that referenced this issue May 15, 2011
thanks to @bagby for reporting
ktoso added a commit that referenced this issue May 15, 2011
the commit.time property was overriden, thus the build time could not be accessed (they used the same property)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants