Skip to content

Commit

Permalink
#2025 skip if repo is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 5, 2024
1 parent 00d9182 commit 3cabbbd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/rultor/Routine.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.jcabi.github.Github;
import com.jcabi.log.Logger;
import com.rultor.agents.Agents;
import com.rultor.agents.github.qtn.DefaultBranch;
import com.rultor.profiles.Profiles;
import com.rultor.spi.Profile;
import com.rultor.spi.Pulse;
Expand Down Expand Up @@ -197,10 +198,14 @@ private int process(final List<Talk> active) throws IOException {
int total = 0;
for (final Talk talk : active) {
++total;
final Profile profile = profiles.fetch(talk);
this.agents.agent(talk, profile).execute(talk);
if (total > Routine.MAX_TALKS) {
break;
try {
final Profile profile = profiles.fetch(talk);
this.agents.agent(talk, profile).execute(talk);
if (total > Routine.MAX_TALKS) {
break;
}
} catch (final DefaultBranch.RepoNotFoundException ex) {
Logger.warn(this, "The repo not found: %[exception]s", ex);
}
}
this.agents.closer().execute(this.talks);
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/rultor/agents/github/qtn/DefaultBranch.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ public String toString() {
String.format("Repo %s has no default branch", this.repo),
ex
);
} catch (final AssertionError ex) {
throw new RepoNotFoundException(this.repo.coordinates().toString(), ex);
}
}

/**
* When repo is not found.
* @since 2.1
*/
public static class RepoNotFoundException extends RuntimeException {
/**
* Serialization marker.
*/
private static final long serialVersionUID = -3860028281726793188L;

/**
* Ctor.
* @param name Name of repo
* @param exp Original problem
*/
public RepoNotFoundException(final String name, final Throwable exp) {
super(String.format("Most probably the repo %s doesn't exist", name), exp);
}
}
}
8 changes: 7 additions & 1 deletion src/main/java/com/rultor/profiles/Profiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
import com.jcabi.aspects.Cacheable;
import com.jcabi.aspects.Immutable;
import com.jcabi.github.Github;
import com.jcabi.github.Repo;
import com.jcabi.github.RtGithub;
import com.jcabi.github.wire.RetryCarefulWire;
import com.jcabi.manifests.Manifests;
import com.jcabi.xml.XML;
import com.rultor.agents.github.TalkIssues;
import com.rultor.agents.github.qtn.DefaultBranch;
import com.rultor.spi.Profile;
import com.rultor.spi.Talk;
import java.io.IOException;
Expand Down Expand Up @@ -168,8 +170,12 @@ private Profile fetch(final XML xml) throws IOException {
final Profile profile;
final List<String> type = xml.xpath("//request/type/text()");
if (type.isEmpty() || !Profiles.MERGE.equals(type.get(0))) {
final Repo repo = new TalkIssues(
Profiles.github(), xml
).get().repo();
profile = new GithubProfile(
new TalkIssues(Profiles.github(), xml).get().repo()
repo,
new DefaultBranch(repo).toString()
);
} else {
profile = this.merged(
Expand Down

0 comments on commit 3cabbbd

Please sign in to comment.