Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Reinstate Gradle 5 compatibility (#144) (#145)
Browse files Browse the repository at this point in the history
## Description
Reinstate Gradle 5 compatibility by working around a bug resolved in gradle/gradle@3f8ddc9
Fixes #144

## Changes
* ![FIX] broken Gradle 5 compatibility


[FIX]:      https://resources.atlas.wooga.com/icons/icon_fix.svg "Fix"
  • Loading branch information
Vampire authored Jun 23, 2023
1 parent 944b8cc commit bbcd184
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ class GithubClientFactory {
Provider<String> password,
Provider<String> token) {
//a non-empty provider if any credentials are available
Provider hasCredsProvider = username.orElse(password).orElse(token).orElse("").
map({
return it == "" && !hasExternalCredentials()? null : true
})
return hasCredsProvider.map({
return username.orElse(password).orElse(token).orElse("").
map {
def hasCreds = it == "" && !hasExternalCredentials()? null : true
if (hasCreds == null) {
return null
}
return new GithubClientFactory().
createGithubClient(username.getOrNull(), password.getOrNull(), token.getOrNull())
})
}
}

private static boolean hasExternalCredentials() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ class RepositoryInfo {

Provider<String> getRepositoryNameFromLocalGit() {
return grgitProvider.map { git ->
git.remote.list().find {it.name == DEFAULT_REMOTE && it.url.contains(GITHUB_DOMAIN)}?: null
}.map{remote ->
def remote = git.remote.list().find {it.name == DEFAULT_REMOTE && it.url.contains(GITHUB_DOMAIN)}?: null
if (remote == null) {
return null
}
def remoteURL = remote.url
def domainIndex = remoteURL.indexOf(GITHUB_DOMAIN)
def urlAfterDomain = remoteURL.substring(domainIndex + GITHUB_DOMAIN.length() + 1)
Expand All @@ -34,11 +36,16 @@ class RepositoryInfo {
}

Provider<String> getBranchNameFromLocalGit() {
return grgitProvider.
map { git -> git.branch.current() }.
map { currentBranch ->
currentBranch.trackingBranch != null ? currentBranch.trackingBranch : currentBranch
}.
map{branch -> branch.name }
return grgitProvider.map { git ->
def currentBranch = git.branch.current()
if (currentBranch == null) {
return null
}
def branch = currentBranch.trackingBranch != null ? currentBranch.trackingBranch : currentBranch
if (branch == null) {
return null
}
branch.name
}
}
}

0 comments on commit bbcd184

Please sign in to comment.