Skip to content

Commit

Permalink
Only create file if existing
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsuter committed Feb 6, 2025
1 parent 7782e1a commit 9e0f663
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 9 additions & 6 deletions src/main/java/io/ivyteam/devops/github/GitHubSynchronizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ public void synch(GHRepository ghRepo) throws IOException {
repos.create(repo);

for (var f : List.of("LICENSE", "SECURITY.md", "CODE_OF_CONDUCT.md", "renovate.json", ".github/renovate.json")) {
var file = File.create()
.repository(repo.name())
.path(f)
.content(readFile(ghRepo, f))
.build();
files.create(file);
var content = readFile(ghRepo, f);
if (content != null && !content.isEmpty()) {
var file = File.create()
.repository(repo.name())
.path(f)
.content(content)
.build();
files.create(file);
}
}

ghRepo.getPullRequests(GHIssueState.OPEN).stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public String check(Repo repo) {
return null;
}
var file = files.byPath(repo, "LICENSE");
if (file == null) {
return "LICENSE file is missing";
}
var content = file.content();
if (content == null || content.isEmpty()) {
return "LICENSE is missing";
return "Content of LICENSE file is empty";
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ public String check(Repo repo) {
return null;
}
var renovateFile = files.byPath(repo, "renovate.json");
if (renovateFile == null || renovateFile.content() == null || renovateFile.content().isEmpty()) {
if (renovateFile == null) {
renovateFile = files.byPath(repo, ".github/renovate.json");
}
if (renovateFile == null) {
return "renovate.json and .github/renovate.json is missing";
}
var content = renovateFile.content();
if (content == null || content.isEmpty()) {
return "renovate.json and .github/renovate.json is missing";
return renovateFile.path() + " is empty";
}
if (!content.contains(SHARED)) {
return "renovate.json does not use shared config '" + SHARED + "'";
return renovateFile + " does not use shared config '" + SHARED + "'";
}
return null;
}
Expand Down

0 comments on commit 9e0f663

Please sign in to comment.