Skip to content

Commit

Permalink
Only exclude fromHash on UPDATE ref changes
Browse files Browse the repository at this point in the history
Bitbucket 5.x does not like excluding null SHA1 commit which is used on
ADD ref changes. This was previously reported as christiangalsterer#33, but got lost in
refactoring.
  • Loading branch information
raspy committed Jan 2, 2018
1 parent 008a3a8 commit 58c6be5
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.atlassian.bitbucket.commit.Commit;
import com.atlassian.bitbucket.content.Change;
import com.atlassian.bitbucket.repository.RefChange;
import com.atlassian.bitbucket.repository.RefChangeType;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.scm.ChangesetsCommandParameters;
import com.atlassian.bitbucket.scm.CommitsCommandParameters;
Expand Down Expand Up @@ -59,16 +60,18 @@ public Map<Commit, Iterable<Change>> getChanges(final Repository repository, Ite
@Override
public Iterable<Commit> getCommitsBetween(final Repository repository, final RefChange refChange) {
List<Commit> commits = new LinkedList<>();
CommitsCommandParameters parameters = new CommitsCommandParameters.Builder()
.exclude(refChange.getFromHash())
CommitsCommandParameters.Builder parameters = new CommitsCommandParameters.Builder()
.include(refChange.getToHash())
.withMessages(false)
.build();
scmService.getCommandFactory(repository).commits(parameters, new AbstractCommitCallback() {
.withMessages(false);

if (refChange.getType() == RefChangeType.UPDATE) {
parameters = parameters.exclude(refChange.getFromHash());
}

scmService.getCommandFactory(repository).commits(parameters.build(), new AbstractCommitCallback() {
@Override
public boolean onCommit(@Nonnull Commit commit) {
commits.add(commit);
return true;
return commits.add(commit);
}
}).call();
return commits;
Expand Down

0 comments on commit 58c6be5

Please sign in to comment.