Skip to content

Commit c0664b6

Browse files
committed
Fix branch builds not updating status due to different repo IDs
Fixes #10.
1 parent d50e8ae commit c0664b6

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

src/main/java/com/mhackner/bamboo/AbstractGitHubStatusAction.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.atlassian.bamboo.utils.BambooUrl;
1515
import com.atlassian.bamboo.utils.SystemProperty;
1616
import com.google.common.base.Function;
17+
import com.google.common.base.Predicate;
18+
import com.google.common.collect.Iterables;
1719
import com.google.common.collect.Lists;
1820

1921
import org.kohsuke.github.GHCommitState;
@@ -70,9 +72,23 @@ public Long apply(RepositoryDefinition input) {
7072
}).toString();
7173
}
7274

73-
for (RepositoryDefinition repo : repos) {
74-
if (configuredRepos.contains(Long.toString(repo.getId()))) {
75-
GitHubRepository ghRepo = Narrow.downTo(repo.getRepository(),
75+
for (final RepositoryDefinition repo : repos) {
76+
RepositoryDefinition topLevelRepo;
77+
if (plan.hasMaster()) {
78+
topLevelRepo = Iterables.find(
79+
repositoryDefinitionManager.getRepositoryDefinitionsForPlan(plan.getMaster()),
80+
new Predicate<RepositoryDefinition>() {
81+
@Override
82+
public boolean apply(RepositoryDefinition input) {
83+
return input.getName().equals(repo.getName());
84+
}
85+
});
86+
} else {
87+
topLevelRepo = repo;
88+
}
89+
90+
if (configuredRepos.contains(Long.toString(topLevelRepo.getId()))) {
91+
GitHubRepository ghRepo = Narrow.downTo(topLevelRepo.getRepository(),
7692
GitHubRepository.class);
7793
assert ghRepo != null; // only GitHub repos are selectable in the UI
7894
String sha = chainExecution.getBuildChanges().getVcsRevisionKey(repo.getId());

0 commit comments

Comments
 (0)