Skip to content

Commit

Permalink
Backward compatibility fix: try old key if new key doesn't work
Browse files Browse the repository at this point in the history
Fixes the case where new plugin is installed and compareRemoteRevisionWith
is called on a build produced with the old version. The new plugin fails
to retrieve the SCMRevisionState objects in this case.
  • Loading branch information
kmbell committed Jan 11, 2012
1 parent 915646e commit 7a9e2b2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public void add(@NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<
} }


public SCMRevisionState get(@NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<?,?> build) { public SCMRevisionState get(@NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<?,?> build) {
return revisionStates.get(keyFor(scm, ws, build)); SCMRevisionState state = revisionStates.get(keyFor(scm, ws, build));
// for backward compatibility with version 0.1, try to get the state using the class name as well
if (state == null)
state = revisionStates.get(scm.getClass().getName());
return state;
} }


private static String keyFor(@NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<?,?> build) { // JENKINS-12298 private static String keyFor(@NonNull SCM scm, @NonNull FilePath ws, @Nullable AbstractBuild<?,?> build) { // JENKINS-12298
Expand Down

0 comments on commit 7a9e2b2

Please sign in to comment.