Skip to content

Commit 62dd76d

Browse files
authored
Add proper logging to see the errors (#438)
1 parent 5c1cad6 commit 62dd76d

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ android {
2424
applicationId "com.jraska.github.client"
2525
minSdkVersion 24
2626
targetSdkVersion 30
27-
versionName '0.23.0'
28-
versionCode 87
27+
versionName '0.23.1'
28+
versionCode 88
2929
multiDexEnabled true
3030

3131
testInstrumentationRunner "com.jraska.github.client.TestRunner"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.jraska.github.client.release
2+
3+
import okhttp3.HttpUrl
4+
import okhttp3.HttpUrl.Companion.toHttpUrl
5+
import java.lang.IllegalStateException
6+
7+
class Environment(
8+
val apiToken: String,
9+
val baseUrl: HttpUrl = "https://api.github.com/repos/jraska/github-client/".toHttpUrl()
10+
) {
11+
companion object {
12+
fun create(): Environment {
13+
val apiToken = System.getenv("TOKEN_GITHUB_API") ?: throw IllegalStateException("GitHub API token missing")
14+
return Environment(apiToken)
15+
}
16+
}
17+
}

plugins/src/main/java/com/jraska/github/client/release/ReleaseMarksPRs.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import okhttp3.HttpUrl.Companion.toHttpUrl
55

66
object ReleaseMarksPRs {
77
fun execute(tag: String) {
8-
val release = Release(tag, "https://github.com/jraska/github-client/releases/tag/$tag".toHttpUrl())
8+
val environment = Environment.create()
9+
val release = Release(tag, "${environment.baseUrl}releases/tag/$tag".toHttpUrl())
910

10-
val api = GitHubApiFactory.create()
11+
val api = GitHubApiFactory.create(environment)
1112
val releaseMarker = ReleaseMarker(api, NotesComposer())
1213

1314
releaseMarker.markPrsWithMilestone(release)

plugins/src/main/java/com/jraska/github/client/release/data/GitHubApiFactory.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.jraska.github.client.release.data
22

3+
import com.jraska.github.client.release.Environment
34
import com.jraska.github.client.release.GitHubApi
45
import okhttp3.OkHttpClient
56
import okhttp3.logging.HttpLoggingInterceptor
@@ -8,16 +9,14 @@ import retrofit2.converter.gson.GsonConverterFactory
89
import java.lang.IllegalStateException
910

1011
object GitHubApiFactory {
11-
fun create(): GitHubApi {
12-
val apiToken = System.getenv("TOKEN_GITHUB_API") ?: throw IllegalStateException("GitHub API token missing")
13-
12+
fun create(environment: Environment): GitHubApi {
1413
val client = OkHttpClient.Builder()
15-
.addInterceptor(GitHubInterceptor(apiToken))
16-
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))
14+
.addInterceptor(GitHubInterceptor(environment.apiToken))
15+
.addInterceptor(HttpLoggingInterceptor { println(it) }.setLevel(HttpLoggingInterceptor.Level.BASIC))
1716
.build()
1817

1918
val retrofit = Retrofit.Builder()
20-
.baseUrl("https://api.github.com/repos/jraska/github-client/")
19+
.baseUrl(environment.baseUrl)
2120
.client(client)
2221
.validateEagerly(true)
2322
.addConverterFactory(GsonConverterFactory.create())

0 commit comments

Comments
 (0)