Merge pull request #2292 from element-hq/feature/bma/gitSha
Git sha and branch in log
This commit is contained in:
commit
f88d96fbc5
13 changed files with 141 additions and 24 deletions
|
|
@ -82,6 +82,7 @@ dependencies {
|
|||
testImplementation(projects.libraries.indicator.impl)
|
||||
testImplementation(projects.features.logout.impl)
|
||||
testImplementation(projects.services.analytics.test)
|
||||
testImplementation(projects.services.toolbox.test)
|
||||
testImplementation(projects.features.analytics.impl)
|
||||
testImplementation(projects.tests.testutils)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,16 @@ class DefaultVersionFormatter @Inject constructor(
|
|||
private val buildMeta: BuildMeta,
|
||||
) : VersionFormatter {
|
||||
override fun get(): String {
|
||||
return stringProvider.getString(
|
||||
val base = stringProvider.getString(
|
||||
CommonStrings.settings_version_number,
|
||||
buildMeta.versionName,
|
||||
buildMeta.versionCode.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class FakeVersionFormatter : VersionFormatter {
|
||||
override fun get(): String {
|
||||
return "A Version"
|
||||
return if (buildMeta.gitBranchName == "main") {
|
||||
base
|
||||
} else {
|
||||
// In case of a build not from main, we display the branch name and the revision
|
||||
"$base\n${buildMeta.gitBranchName}\n${buildMeta.gitRevision}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2024 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.preferences.impl.root
|
||||
|
||||
class FakeVersionFormatter : VersionFormatter {
|
||||
override fun get(): String {
|
||||
return "A Version"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2024 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.element.android.features.preferences.impl.root
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.test.core.aBuildMeta
|
||||
import io.element.android.services.toolbox.test.strings.FakeStringProvider
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
class VersionFormatterTest {
|
||||
@Test
|
||||
fun `version formatter should return simplified version for other branch`() = runTest {
|
||||
val sut = DefaultVersionFormatter(
|
||||
stringProvider = FakeStringProvider(defaultResult = VERSION),
|
||||
buildMeta = aBuildMeta(gitBranchName = "main")
|
||||
)
|
||||
assertThat(sut.get()).isEqualTo(VERSION)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `version formatter should return simplified version for main branch`() = runTest {
|
||||
val sut = DefaultVersionFormatter(
|
||||
stringProvider = FakeStringProvider(defaultResult = VERSION),
|
||||
buildMeta = aBuildMeta(
|
||||
gitBranchName = "branch",
|
||||
gitRevision = "1234567890",
|
||||
)
|
||||
)
|
||||
assertThat(sut.get()).isEqualTo("$VERSION\nbranch\n1234567890")
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val VERSION = "version"
|
||||
}
|
||||
}
|
||||
|
|
@ -202,6 +202,8 @@ class DefaultBugReporter @Inject constructor(
|
|||
// add some github labels
|
||||
builder.addFormDataPart("label", buildMeta.versionName)
|
||||
builder.addFormDataPart("label", buildMeta.flavorDescription)
|
||||
builder.addFormDataPart("branch_name", buildMeta.gitBranchName)
|
||||
|
||||
if (crashCallStack.isNotEmpty() && withCrashLogs) {
|
||||
builder.addFormDataPart("label", "crash")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class DefaultBugReporterTest {
|
|||
server.shutdown()
|
||||
assertThat(onUploadCancelledCalled).isFalse()
|
||||
assertThat(onUploadFailedCalled).isFalse()
|
||||
assertThat(progressValues.size).isEqualTo(11)
|
||||
assertThat(progressValues.size).isEqualTo(EXPECTED_NUMBER_OF_PROGRESS_VALUE)
|
||||
assertThat(onUploadSucceedCalled).isTrue()
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ class DefaultBugReporterTest {
|
|||
assertThat(onUploadCancelledCalled).isFalse()
|
||||
assertThat(onUploadFailedCalled).isTrue()
|
||||
assertThat(onUploadFailedReason).isEqualTo("An error body")
|
||||
assertThat(progressValues.size).isEqualTo(11)
|
||||
assertThat(progressValues.size).isEqualTo(EXPECTED_NUMBER_OF_PROGRESS_VALUE)
|
||||
assertThat(onUploadSucceedCalled).isFalse()
|
||||
}
|
||||
|
||||
|
|
@ -153,4 +153,8 @@ class DefaultBugReporterTest {
|
|||
bugReporterUrlProvider = { server.url("/") }
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val EXPECTED_NUMBER_OF_PROGRESS_VALUE = 12
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue