Skip to content

Commit 06b84e0

Browse files
committed
rename SpecifiedBranchCommit2 to SpecifiedBranchCommitMergeBase
1 parent 0f16ade commit 06b84e0

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ affectedModuleDetector {
113113
- PreviousCommit: compare against the previous commit
114114
- ForkCommit: compare against the commit the branch was forked from
115115
- SpecifiedBranchCommit: compare against the last commit of `$specifiedBranch` using `git rev-parse` approach.
116-
- SpecifiedBranchCommit2: compare against the nearest ancestors with `$specifiedBranch` using `git merge base` approach.
116+
- SpecifiedBranchCommitMergeBase: compare against the nearest ancestors with `$specifiedBranch` using `git merge base` approach.
117117

118118
**Note:** specify the branch to compare changes against using the `specifiedBranch` configuration before the `compareFrom` configuration
119119
- `excludedModules`: A list of modules that will be excluded from the build process
@@ -135,10 +135,10 @@ affectedModuleDetector {
135135
* `./gradlew runAffectedAndroidTests` - runs connected tests
136136
* `./gradlew assembleAffectedAndroidTests` - assembles but does not run on device tests, useful when working with device labs
137137

138-
## SpecifiedBranchCommit vs SpecifiedBranchCommit2
138+
## SpecifiedBranchCommit vs SpecifiedBranchCommitMergeBase
139139

140140
- SpecifiedBranchCommit using `git rev-parse` command for getting sha.
141-
- SpecifiedBranchCommit2 using `git merge base` command for getting sha.
141+
- SpecifiedBranchCommitMergeBase using `git merge base` command for getting sha.
142142

143143
What does it mean?
144144
When we run any AMD command we compare the current branch with the specified parent branch. Consider an example when, during the development of our feature,
@@ -151,7 +151,7 @@ Suppose we have changed 6 files in our "feature" branch.
151151

152152
1. Behaviour of SpecifiedBranchCommit:
153153
AMD will show the result that 15 files were affected. Because our branch is not updated (pull) and AMD will see our 6 files and 9 files that were merged by another developer.
154-
2. Behaviour of SpecifiedBranchCommit2:
154+
2. Behaviour of SpecifiedBranchCommitMergeBase:
155155
AMD will show the result that 6 files were affected. And this is the correct behavior.
156156

157157
Hence, depends on your CI settings you have to configure AMD right.

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleConfiguration.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ class AffectedModuleConfiguration {
8585
"PreviousCommit",
8686
"ForkCommit",
8787
"SpecifiedBranchCommit",
88-
"SpecifiedBranchCommit2"
88+
"SpecifiedBranchCommitMergeBase"
8989
)
9090
require(commitShaProviders.contains(value)) {
9191
"The property configuration compareFrom must be one of the following: ${commitShaProviders.joinToString(", ")}"
9292
}
93-
if (value == "SpecifiedBranchCommit" || value == "SpecifiedBranchCommit2") {
93+
if (value == "SpecifiedBranchCommit" || value == "SpecifiedBranchCommitMergeBase") {
9494
requireNotNull(specifiedBranch) {
9595
"Specify a branch using the configuration specifiedBranch"
9696
}

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/CommitShaProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ interface CommitShaProvider {
1818
}
1919
SpecifiedBranchCommit(specifiedBranch)
2020
}
21-
"SpecifiedBranchCommit2" -> {
21+
"SpecifiedBranchCommitMergeBase" -> {
2222
requireNotNull(specifiedBranch) {
2323
"Specified branch must be defined"
2424
}
25-
SpecifiedBranchCommit2(specifiedBranch)
25+
SpecifiedBranchCommitMergeBase(specifiedBranch)
2626
}
2727
else -> throw IllegalArgumentException("Unsupported compareFrom type")
2828
}

affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/SpecifiedBranchCommit2.kt renamed to affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/SpecifiedBranchCommitMergeBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.dropbox.affectedmoduledetector.commitshaproviders
33
import com.dropbox.affectedmoduledetector.GitClient
44
import com.dropbox.affectedmoduledetector.Sha
55

6-
class SpecifiedBranchCommit2(private val specifiedBranch: String) : CommitShaProvider {
6+
class SpecifiedBranchCommitMergeBase(private val specifiedBranch: String) : CommitShaProvider {
77

88
override fun get(commandRunner: GitClient.CommandRunner): Sha {
99
val currentBranch = commandRunner.executeAndParseFirst(CURRENT_BRANCH_CMD)

affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleConfigurationTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,24 +173,24 @@ class AffectedModuleConfigurationTest {
173173
}
174174

175175
@Test
176-
fun `WHEN compareFrom is set to SpecifiedBranchCommit2 AND specifiedBranch is set THEN return SpecifiedBranchCommit2`() {
177-
val specifiedBranchCommit2 = "SpecifiedBranchCommit2"
176+
fun `WHEN compareFrom is set to SpecifiedBranchCommitMergeBase AND specifiedBranch is set THEN return SpecifiedBranchCommitMergeBase`() {
177+
val specifiedBranchCommitMergeBase = "SpecifiedBranchCommitMergeBase"
178178
val specifiedBranch = "origin/dev"
179179

180180
config.specifiedBranch = specifiedBranch
181-
config.compareFrom = specifiedBranchCommit2
181+
config.compareFrom = specifiedBranchCommitMergeBase
182182

183183
val actual = config.compareFrom
184184

185-
assertThat(actual).isEqualTo(specifiedBranchCommit2)
185+
assertThat(actual).isEqualTo(specifiedBranchCommitMergeBase)
186186
}
187187

188188
@Test
189-
fun `WHEN compareFrom is set to SpecifiedBranchCommit2 AND specifiedBranch isn't set THEN throw exception`() {
190-
val specifiedBranchCommit2 = "SpecifiedBranchCommit2"
189+
fun `WHEN compareFrom is set to SpecifiedBranchCommitMergeBase AND specifiedBranch isn't set THEN throw exception`() {
190+
val specifiedBranchCommitMergeBase = "SpecifiedBranchCommitMergeBase"
191191

192192
try {
193-
config.compareFrom = specifiedBranchCommit2
193+
config.compareFrom = specifiedBranchCommitMergeBase
194194
} catch (e: IllegalArgumentException) {
195195
assertThat(e.message).isEqualTo("Specify a branch using the configuration specifiedBranch")
196196
}
@@ -241,7 +241,7 @@ class AffectedModuleConfigurationTest {
241241
fail()
242242
} catch (e: Exception) {
243243
assertThat(e::class).isEqualTo(IllegalArgumentException::class)
244-
assertThat(e.message).isEqualTo("The property configuration compareFrom must be one of the following: PreviousCommit, ForkCommit, SpecifiedBranchCommit, SpecifiedBranchCommit2")
244+
assertThat(e.message).isEqualTo("The property configuration compareFrom must be one of the following: PreviousCommit, ForkCommit, SpecifiedBranchCommit, SpecifiedBranchCommitMergeBase")
245245
assertThat(config.compareFrom).isEqualTo("PreviousCommit")
246246
}
247247
}

affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/CommitShaProviderTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ class CommitShaProviderTest {
4242
}
4343

4444
@Test
45-
fun givenSpecifiedBranchCommit2AndSpecifiedBranchNull_whenFromString_thenThrowException() {
45+
fun givenSpecifiedBranchCommitMergeBaseAndSpecifiedBranchNull_whenFromString_thenThrowException() {
4646
try {
47-
CommitShaProvider.fromString("SpecifiedBranchCommit2")
47+
CommitShaProvider.fromString("SpecifiedBranchCommitMergeBase")
4848
} catch (e: Exception) {
4949
assertThat(e::class).isEqualTo(IllegalArgumentException::class)
5050
assertThat(e.message).isEqualTo("Specified branch must be defined")
5151
}
5252
}
5353

5454
@Test
55-
fun givenSpecifiedBranchCommit2_whenFromString_thenReturnSpecifiedBranchCommit2() {
56-
val actual = CommitShaProvider.fromString("SpecifiedBranchCommit2", "branch")
55+
fun givenSpecifiedBranchCommitMergeBase_whenFromString_thenReturnSpecifiedBranchCommitMergeBase() {
56+
val actual = CommitShaProvider.fromString("SpecifiedBranchCommitMergeBase", "branch")
5757

58-
assertThat(actual::class).isEqualTo(SpecifiedBranchCommit2::class)
58+
assertThat(actual::class).isEqualTo(SpecifiedBranchCommitMergeBase::class)
5959
}
6060

6161
@Test

affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/SpecifiedBranchCommit2Test.kt renamed to affectedmoduledetector/src/test/kotlin/com/dropbox/affectedmoduledetector/commitshaproviders/SpecifiedBranchCommitMergeBaseTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ import org.junit.runner.RunWith
99
import org.junit.runners.JUnit4
1010

1111
@RunWith(JUnit4::class)
12-
class SpecifiedBranchCommit2Test {
12+
class SpecifiedBranchCommitMergeBaseTest {
1313

1414
@Rule
1515
@JvmField
1616
val attachLogsRule = AttachLogsTestRule()
1717
private val logger = attachLogsRule.logger
1818
private val commandRunner = MockCommandRunner(logger)
19-
private val previousCommit = SpecifiedBranchCommit2(SPECIFIED_BRANCH)
19+
private val previousCommit = SpecifiedBranchCommitMergeBase(SPECIFIED_BRANCH)
2020

2121
@Test
2222
fun `WHEN CURRENT_BRANCH_CMD THEN command returned`() {
23-
Truth.assertThat(SpecifiedBranchCommit2.CURRENT_BRANCH_CMD).isEqualTo("git rev-parse --abbrev-ref HEAD")
23+
Truth.assertThat(SpecifiedBranchCommitMergeBase.CURRENT_BRANCH_CMD).isEqualTo("git rev-parse --abbrev-ref HEAD")
2424
}
2525

2626
@Test
2727
fun `WHEN get commit sha THEN return sha`() {
2828

29-
commandRunner.addReply(SpecifiedBranchCommit2.CURRENT_BRANCH_CMD, NEW_FEATURE_BRANCH)
29+
commandRunner.addReply(SpecifiedBranchCommitMergeBase.CURRENT_BRANCH_CMD, NEW_FEATURE_BRANCH)
3030
commandRunner.addReply("git merge-base $NEW_FEATURE_BRANCH $SPECIFIED_BRANCH", "commit-sha")
3131

3232
val actual = previousCommit.get(commandRunner)

sample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ affectedModuleDetector {
3232
"buildSrc/"
3333
]
3434
specifiedBranch = "origin/main"
35-
compareFrom = "SpecifiedBranchCommit2"
35+
compareFrom = "SpecifiedBranchCommitMergeBase"
3636
customTasks = [
3737
new AffectedModuleConfiguration.CustomTask(
3838
"runDetektByImpact",

0 commit comments

Comments
 (0)