Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@

# macOS
.DS_Store

# Eclipse files
/.classpath
/.project
/bin/
/.settings/org.eclipse.buildship.core.prefs
29 changes: 21 additions & 8 deletions src/main/java/io/papermc/fill/gradle/task/PublishToFillTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private List<Commit> gatherCommits(Git git, FillExtension extension) {
final RevCommit currentCommit = revWalk.parseCommit(git.getRepository().exactRef(Constants.HEAD).getObjectId());
revWalk.markStart(currentCommit);

final List<BuildResponse> builds = this.fetchLastVersionBuilds(extension);
final List<BuildResponse> builds = this.fetchPreviousBuilds(extension);
if (!builds.isEmpty()) {
// not every build might have commits, we have to find the last one that did have some
BuildResponse lastBuildWithCommits = null;
Expand Down Expand Up @@ -239,17 +239,30 @@ private List<Commit> gatherCommits(Git git, FillExtension extension) {
return commits;
}

private List<BuildResponse> fetchLastVersionBuilds(final FillExtension extension) {
private List<BuildResponse> fetchPreviousBuilds(final FillExtension extension) {
final String currentVersion = extension.getVersion().get();
final VersionsResponse versions = this.getVersions(extension);
String lastVersionWithBuild = null;

// Check if the current version already has builds
for (final VersionResponse version : versions.versions()) {
if (!version.builds().isEmpty()) {
lastVersionWithBuild = version.version().id();
break;
if (version.version().id().equals(currentVersion) && !version.builds().isEmpty()) {
return this.fetchCurrentVersionBuilds(extension, currentVersion);
}
}
if (lastVersionWithBuild != null) {
return this.getBuilds(extension, lastVersionWithBuild);

// For new versions without builds, fall back to finding the last version with builds
return this.fetchLastVersionBuilds(extension, versions);
}

private List<BuildResponse> fetchCurrentVersionBuilds(final FillExtension extension, final String version) {
return this.getBuilds(extension, version);
}

private List<BuildResponse> fetchLastVersionBuilds(final FillExtension extension, final VersionsResponse versions) {
for (final VersionResponse version : versions.versions()) {
if (!version.builds().isEmpty()) {
return this.getBuilds(extension, version.version().id());
}
}
return List.of();
}
Expand Down