Skip to content
Permalink
Browse files

[JENKINS-17604] Better equals for Git

  • Loading branch information
wolfgarnet committed Apr 14, 2013
1 parent 7ed417b commit c81f647086c3d79a9ca73021d123fe84591a9835
@@ -40,6 +40,33 @@ public void checkout( FilePath workspace, TaskListener listener ) throws IOExcep
}
}

@Override
public boolean equals( Object other ) {
if( other == this ) {
return true;
}

if( other instanceof GitConfiguration ) {
GitConfiguration o = (GitConfiguration) other;
/* Check size */
if( o.getList().size() != list.size() ) {
return false;
}

/* Check elements, the size is identical */
for( int i = 0; i < list.size(); ++i ) {
if( !o.list.get( i ).equals( list.get( i ) ) ) {
return false;
}
}

/* Everything is ok */
return true;
} else {

This comment has been minimized.

Copy link
@MadsNielsen

MadsNielsen Apr 17, 2013

Member

Shouldn't you return false here? If you pass in another kind of object the current git configuration would be equal to any kind of other object?

return true;
}
}

@Override
public List<ConfigRotatorChangeLogEntry> difference( GitConfigurationComponent component, GitConfigurationComponent other ) throws ConfigurationRotatorException {
return null; //To change body of implemented methods use File | Settings | File Templates.
@@ -86,9 +86,27 @@ public String getFeedName() {
return repository;
}

@Override
public boolean equals( Object other ) {
if( other == this ) {
return true;
}

if( other instanceof GitConfigurationComponent ) {
GitConfigurationComponent o = (GitConfigurationComponent) other;

logger.finest( "Other: " + o.commitId + " == " + commitId );

return ( o.commitId.equals( commitId ) && ( o.isFixed() == fixed ) );
} else {
return false;
}
}

@Override
public String toString() {
return "GitComponent[" + name + ": " + repository + ", " + branch + ", " + commitId + "]";
//return "GitComponent[" + name + ": " + repository + ", " + branch + ", " + commitId + "]";
return "GC[" + commitId + "]";
}

@Override
@@ -82,7 +82,8 @@ public boolean equals( Object other ) {
if( other instanceof GitTarget ) {
GitTarget o = (GitTarget)other;

return repository.equals( o.repository );
//return repository.equals( o.repository );
return commitId.equals( o.commitId );
} else {
return false;
}

0 comments on commit c81f647

Please sign in to comment.
You can’t perform that action at this time.