|
14 | 14 | import com.atlassian.bamboo.utils.BambooUrl; |
15 | 15 | import com.atlassian.bamboo.utils.SystemProperty; |
16 | 16 | import com.google.common.base.Function; |
| 17 | +import com.google.common.base.Predicate; |
| 18 | +import com.google.common.collect.Iterables; |
17 | 19 | import com.google.common.collect.Lists; |
18 | 20 |
|
19 | 21 | import org.kohsuke.github.GHCommitState; |
@@ -70,9 +72,23 @@ public Long apply(RepositoryDefinition input) { |
70 | 72 | }).toString(); |
71 | 73 | } |
72 | 74 |
|
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(), |
76 | 92 | GitHubRepository.class); |
77 | 93 | assert ghRepo != null; // only GitHub repos are selectable in the UI |
78 | 94 | String sha = chainExecution.getBuildChanges().getVcsRevisionKey(repo.getId()); |
|
0 commit comments