Skip to content

Commit 82acb08

Browse files
committed
Add support from #279 for custom base sha
1 parent b0cd275 commit 82acb08

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,13 @@ abstract class AffectedModuleDetector(protected val logger: Logger?) {
202202
val gitClient = GitClientImpl(
203203
rootProject.projectDir,
204204
logger,
205-
commitShaProviderConfiguration = CommitShaProviderConfiguration(config.compareFrom, config.specifiedBranch, config.top, config.includeUncommitted),
205+
commitShaProviderConfiguration = CommitShaProviderConfiguration(
206+
type = config.compareFrom,
207+
specifiedBranch = config.specifiedBranch,
208+
specifiedSha = config.specifiedRawCommitSha,
209+
top = config.top,
210+
includeUncommitted = config.includeUncommitted
211+
),
206212
ignoredFiles = config.ignoredFiles
207213
)
208214

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.dropbox.affectedmoduledetector.commitshaproviders.ForkCommit
2626
import com.dropbox.affectedmoduledetector.commitshaproviders.PreviousCommit
2727
import com.dropbox.affectedmoduledetector.commitshaproviders.SpecifiedBranchCommit
2828
import com.dropbox.affectedmoduledetector.commitshaproviders.SpecifiedBranchCommitMergeBase
29+
import com.dropbox.affectedmoduledetector.commitshaproviders.SpecifiedRawCommitSha
2930
import com.dropbox.affectedmoduledetector.util.toOsSpecificLineEnding
3031
import com.dropbox.affectedmoduledetector.util.toOsSpecificPath
3132
import org.gradle.api.Project
@@ -228,6 +229,7 @@ internal abstract class GitChangedFilesSource :
228229

229230
private fun getSha(): Sha {
230231
val specifiedBranch = parameters.commitShaProvider.specifiedBranch
232+
val specifiedSha = parameters.commitShaProvider.specifiedSha
231233
val type = when (parameters.commitShaProvider.type) {
232234
"PreviousCommit" -> PreviousCommit()
233235
"ForkCommit" -> ForkCommit()
@@ -243,6 +245,12 @@ internal abstract class GitChangedFilesSource :
243245
}
244246
SpecifiedBranchCommitMergeBase(specifiedBranch)
245247
}
248+
"SpecifiedRawCommitSha" -> {
249+
requireNotNull(specifiedSha) {
250+
"Provide a Commit SHA for the specifiedRawCommitSha property when using SpecifiedRawCommitSha comparison strategy."
251+
}
252+
SpecifiedRawCommitSha(specifiedSha)
253+
}
246254
else -> throw IllegalArgumentException("Unsupported compareFrom type")
247255
}
248256
return type.get(commandRunner)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface CommitShaProvider : Serializable {
1111
data class CommitShaProviderConfiguration(
1212
val type: String,
1313
val specifiedBranch: String? = null,
14+
val specifiedSha: String? = null,
1415
val top: Sha,
1516
val includeUncommitted: Boolean
1617
) : Serializable

0 commit comments

Comments
 (0)