forked from mauricioaniche/repodriller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A Changeset now includes a message as well as author/committer objects modeled on JGit's PersonIdent. This is a breaking change for anyone who uses ChangeSet. The payoff is that on complex git-based repositories, users can now better handle the distributed nature of git. The time-based CommitRanges provided by RepoDriller now use the committer time when doing time comparisons. This is what the user generally intends: "the time at which this commit entered the repository". Addresses mauricioaniche#96.
- Loading branch information
Showing
16 changed files
with
344 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package org.repodriller.domain; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
/** | ||
* A POJO to track details about a person involved with a commit. | ||
*/ | ||
public class CommitPerson { | ||
public String name; | ||
public String email; | ||
public Calendar time; | ||
|
||
public CommitPerson(String author, String email, Calendar time) { | ||
this.name = author; | ||
this.email = email; | ||
this.time = time; | ||
} | ||
|
||
public CommitPerson(CommitPerson c) { | ||
this.name = c.name; | ||
this.email = c.email; | ||
this.time = c.time; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s <%s> at %s", name, email, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(time)); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime1 = 17; | ||
final int prime2 = 31; | ||
|
||
int hash = prime1; | ||
|
||
/* I'm sure there's a more efficient way to do this... */ | ||
List<Object> members = new ArrayList<Object>(); | ||
members.add(name); | ||
members.add(email); | ||
members.add(time); | ||
|
||
for (Object member : members) { | ||
hash = prime2*hash + ((member == null) ? 0 : member.hashCode()); | ||
} | ||
|
||
return hash; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
/* Boilerplate. */ | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
|
||
/* Compare two distinct instances. */ | ||
CommitPerson other = (CommitPerson) obj; | ||
|
||
if (name == null) { | ||
if (other.name != null) | ||
return false; | ||
} | ||
else { | ||
if (!name.equals(other.name)) | ||
return false; | ||
} | ||
|
||
if (email == null) { | ||
if (other.email != null) | ||
return false; | ||
} | ||
else { | ||
if (!email.equals(other.name)) | ||
return false; | ||
} | ||
|
||
if (time == null) { | ||
if (other.time != null) | ||
return false; | ||
} | ||
else { | ||
if (!time.equals(other.name)) | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.