Skip to content
This repository was archived by the owner on May 8, 2024. It is now read-only.

Commit 75b81f6

Browse files
Merge pull request #55 from stack-spot/release-1.0.0
Release 1.0.0
2 parents a5f2a1f + 6979c85 commit 75b81f6

32 files changed

+732
-147
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,25 @@
22

33
## Releases
44

5+
## [v1.0.0] - 2022-10-06
6+
<!-- Release notes generated using configuration in .github/release.yaml at release-1.0.0 -->
7+
8+
### Exciting New Features 🎉
9+
* Feature: Improve code coverage with unit tests by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/48
10+
### Bug Fixes 🛠
11+
* Bug Fix: Add mock for git config command runner by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/53
12+
13+
14+
Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.1.4...v1.0.0
15+
516
## [v0.1.4] - 2022-09-21
617
<!-- Release notes generated using configuration in .github/release.yaml at release-0.1.4 -->
7-
818
### Exciting New Features 🎉
919
* Feature: Improve plugin description in marketplace page by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/19
1020
* Feature: changed the documentation url inside the readme by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/22
1121
* Feature: Created workflow to generate release notes and publish plugin by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/23
1222
* Feature: Add Sonarqube and first unit tests by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/33
23+
1324
### Bug Fixes 🛠
1425
* Bug fix: Project wizard always stuck in "no stackfiles panel" by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/17
1526
* Bug fix: Stack url dialog by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/18
@@ -19,7 +30,8 @@
1930
* Bug Fix: Moved changelog jobs into deploy prod workflow by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/28
2031
* Bug Fix: Changed changelog extension in build gradle and disable buildSearchableOptions by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/29
2132
* Bug Fix: Added project version property in update changelog command by @adroaldonetozup in https://github.com/stack-spot/stackspot-intellij-extension/pull/30
33+
2234
### Other Changes
2335
* Refactor: Change reusable workflows to use the main branch instead of release branch by @matheusferreirazup in https://github.com/stack-spot/stackspot-intellij-extension/pull/24
2436

25-
Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.0.3...v0.1.4
37+
Full Changelog: https://github.com/stack-spot/stackspot-intellij-extension/compare/v0.0.3...v0.1.4

build.gradle.kts

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.gradle.api.tasks.testing.logging.TestLogEvent
12
import org.jetbrains.changelog.date
23

34
fun properties(key: String) = project.findProperty(key).toString()
@@ -27,8 +28,11 @@ repositories {
2728
}
2829

2930
dependencies {
30-
testImplementation(platform("org.junit:junit-bom:5.9.0"))
31+
testImplementation(platform("org.junit:junit-bom:5.9.1"))
3132
testImplementation("org.junit.jupiter:junit-jupiter")
33+
testImplementation("io.mockk:mockk:1.13.1")
34+
testImplementation("io.kotest:kotest-assertions-core:5.4.2")
35+
testImplementation("org.awaitility:awaitility-kotlin:4.2.0")
3236
}
3337

3438
kotlin {
@@ -52,8 +56,26 @@ intellij {
5256
}
5357

5458
sonarqube {
59+
val exclusions = listOf(
60+
"**/com/stackspot/constants/**",
61+
"**/com/stackspot/exceptions/**",
62+
"**/com/stackspot/intellij/actions/**",
63+
"**/com/stackspot/intellij/commands/git/**",
64+
"**/com/stackspot/intellij/commands/listeners/**",
65+
"**/com/stackspot/intellij/commands/stk/**",
66+
"**/com/stackspot/intellij/listeners/**",
67+
"**/com/stackspot/intellij/messaging/**",
68+
"**/com/stackspot/intellij/ui/**",
69+
"**/com/stackspot/model/Plugin.kt",
70+
"**/com/stackspot/model/Stackfile.kt",
71+
"**/com/stackspot/model/StackfilePlugin.kt",
72+
"**/com/stackspot/model/StackfileUseCase.kt",
73+
"**/com/stackspot/model/TemplateType.kt",
74+
)
75+
5576
properties {
5677
property("sonar.projectName", "ide-intellij-plugin")
78+
property("sonar.coverage.exclusions", exclusions)
5779
}
5880
}
5981

@@ -107,7 +129,7 @@ tasks {
107129
test {
108130
useJUnitPlatform()
109131
testLogging {
110-
events("passed", "skipped", "failed")
132+
events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
111133
}
112134
finalizedBy(jacocoTestReport)
113135
}
@@ -117,5 +139,27 @@ tasks {
117139
reports {
118140
xml.required.set(true)
119141
}
142+
classDirectories.setFrom(
143+
files(classDirectories.files.map {
144+
fileTree(it) {
145+
exclude(
146+
"com/stackspot/constants/*",
147+
"com/stackspot/exceptions/*",
148+
"com/stackspot/intellij/actions/*",
149+
"com/stackspot/intellij/commands/git/*",
150+
"com/stackspot/intellij/commands/listeners/*",
151+
"com/stackspot/intellij/commands/stk/*",
152+
"com/stackspot/intellij/listeners/*",
153+
"com/stackspot/intellij/messaging/*",
154+
"com/stackspot/intellij/ui/*",
155+
"com/stackspot/model/Plugin.kt",
156+
"com/stackspot/model/Stackfile.kt",
157+
"com/stackspot/model/StackfilePlugin.kt",
158+
"com/stackspot/model/StackfileUseCase.kt",
159+
"com/stackspot/model/TemplateType.kt",
160+
)
161+
}
162+
})
163+
)
120164
}
121165
}

gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ platformType = IC
2525
platformVersion = 2022.1
2626
platformPlugins = org.jetbrains.plugins.terminal, com.intellij.gradle, org.jetbrains.idea.maven
2727

28-
gradleVersion = 7.5.1
28+
gradleVersion = 7.4
2929

3030
# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
3131
# suppress inspection "UnusedProperty"
32-
kotlin.stdlib.default.dependency = false
32+
kotlin.stdlib.default.dependency = false
33+
34+
org.gradle.jvmargs=-Xmx2048M

src/main/kotlin/com/stackspot/constants/Constants.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package com.stackspot.constants
1818

1919
import java.nio.file.Path
2020
import kotlin.io.path.Path
21-
import kotlin.io.path.exists
2221

2322
object Constants {
2423
const val MODULE_TYPE = "STACK_SPOT_TYPE"

src/main/kotlin/com/stackspot/intellij/commands/BackgroundCommandRunner.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ import com.intellij.execution.configurations.GeneralCommandLine
2020
import com.intellij.execution.util.ExecUtil.execAndGetOutput
2121
import java.nio.charset.Charset
2222

23-
class BackgroundCommandRunner(private val workingDir: String) : CommandRunner {
23+
class BackgroundCommandRunner(private var workingDir: String) : CommandRunner {
2424

2525
var stdout: String = ""
2626
get() {
2727
return field.replace("\\n".toRegex(), "")
2828
}
2929
lateinit var stderr: String
30+
var exitCode: Int = 0
31+
var timeout: Boolean = false
32+
var cancelled: Boolean = false
3033

3134
override fun run(commandLine: List<String>, listener: CommandRunner.CommandEndedListener?) {
3235
val generalCommandLine = GeneralCommandLine(commandLine)
@@ -36,6 +39,9 @@ class BackgroundCommandRunner(private val workingDir: String) : CommandRunner {
3639
val processOutput = execAndGetOutput(generalCommandLine)
3740
stdout = processOutput.stdout
3841
stderr = processOutput.stderr
42+
exitCode = processOutput.exitCode
43+
timeout = processOutput.isTimeout
44+
cancelled = processOutput.isCancelled
3945
listener?.notifyEnded()
4046
}
4147
}

src/main/kotlin/com/stackspot/intellij/commands/git/GitBranch.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ package com.stackspot.intellij.commands.git
1818

1919
import com.stackspot.intellij.commands.BackgroundCommandRunner
2020
import com.stackspot.intellij.commands.BaseCommand
21-
import com.stackspot.model.Stack
2221

23-
class GitBranch(stack: Stack, private val flags: Array<String>) :
24-
BaseCommand(BackgroundCommandRunner(stack.location.toPath().toString())) {
22+
class GitBranch(var workingDir: String, private val flags: Array<String>) :
23+
BaseCommand(BackgroundCommandRunner(workingDir)) {
2524

2625
override fun commandLine(): List<String> {
2726
return listOf("git", "branch", *flags)

src/main/kotlin/com/stackspot/intellij/commands/git/GitConfig.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ package com.stackspot.intellij.commands.git
1919
import com.stackspot.intellij.commands.BackgroundCommandRunner
2020
import com.stackspot.intellij.commands.BaseCommand
2121

22-
class GitConfig(workingDirectory: String, private val flags: Array<String>) :
22+
class GitConfig(var workingDirectory: String) :
2323
BaseCommand(BackgroundCommandRunner(workingDirectory)) {
2424

25+
var flags: Array<String> = arrayOf()
26+
2527
override fun commandLine(): List<String> {
2628
return listOf("git", "config", *flags)
2729
}

src/main/kotlin/com/stackspot/intellij/services/CreateProjectService.kt

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,35 @@ import java.util.concurrent.Executors
2929
import java.util.concurrent.TimeUnit
3030

3131
@Service
32-
class CreateProjectService {
32+
class CreateProjectService() {
3333

3434
var stack: Stack? = null
3535
var stackfile: Stackfile? = null
3636
val state: ProjectWizardState
3737
get() {
38-
return if (!Constants.Paths.STK_BIN.exists()) {
38+
return if (!isInstalled) {
3939
ProjectWizardState.NOT_INSTALLED
40-
} else if (!ImportedStacks().hasStackFiles()) {
40+
} else if (!importedStacks.hasStackFiles()) {
4141
ProjectWizardState.STACKFILES_EMPTY
4242
} else if (!isGitConfigOk()) {
4343
ProjectWizardState.GIT_CONFIG_NOT_OK
4444
} else {
4545
ProjectWizardState.OK
4646
}
4747
}
48+
private var isInstalled = Constants.Paths.STK_BIN.exists()
49+
private var importedStacks = ImportedStacks()
50+
private var gitConfigCmd = GitConfig(Constants.Paths.STK_HOME.toString())
51+
52+
constructor(
53+
importedStacks: ImportedStacks = ImportedStacks(),
54+
isInstalled: Boolean = Constants.Paths.STK_BIN.exists(),
55+
gitConfigCmd: GitConfig = GitConfig(Constants.Paths.STK_HOME.toString())
56+
) : this() {
57+
this.importedStacks = importedStacks
58+
this.isInstalled = isInstalled
59+
this.gitConfigCmd = gitConfigCmd
60+
}
4861

4962
fun isStackfileSelected(): Boolean = stack != null && stackfile != null
5063

@@ -62,9 +75,11 @@ class CreateProjectService {
6275
fun addGitConfig(username: String, email: String) {
6376
val executor = Executors.newSingleThreadExecutor()
6477
executor.submit {
65-
val workingDir = Constants.Paths.STK_HOME.toString()
66-
GitConfig(workingDir, arrayOf("--global", "user.name", "\"$username\"")).run()
67-
GitConfig(workingDir, arrayOf("--global", "user.email", "\"$email\"")).run()
78+
gitConfigCmd.flags = arrayOf("--global", "user.name", "\"$username\"")
79+
gitConfigCmd.run()
80+
81+
gitConfigCmd.flags = arrayOf("--global", "user.email", "\"$email\"")
82+
gitConfigCmd.run()
6883
}
6984
executor.shutdown()
7085
}
@@ -87,14 +102,14 @@ class CreateProjectService {
87102
}
88103

89104
private fun getEmailGitConfig(): String {
90-
val gitConfigUserEmail = GitConfig(Constants.Paths.STK_HOME.toString(), arrayOf("--get", "user.email"))
91-
gitConfigUserEmail.run()
92-
return (gitConfigUserEmail.runner as BackgroundCommandRunner).stdout
105+
gitConfigCmd.flags = arrayOf("--get", "user.email")
106+
gitConfigCmd.run()
107+
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
93108
}
94109

95110
private fun getUsernameGitConfig(): String {
96-
val gitConfigUserName = GitConfig(Constants.Paths.STK_HOME.toString(), arrayOf("--get", "user.name"))
97-
gitConfigUserName.run()
98-
return (gitConfigUserName.runner as BackgroundCommandRunner).stdout
111+
gitConfigCmd.flags = arrayOf("--get", "user.name")
112+
gitConfigCmd.run()
113+
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
99114
}
100115
}

src/main/kotlin/com/stackspot/intellij/services/GetDocumentationService.kt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.stackspot.intellij.services
1818

1919
import com.intellij.openapi.components.Service
2020
import com.intellij.util.containers.isNullOrEmpty
21+
import com.stackspot.constants.Constants
2122
import com.stackspot.intellij.commands.BackgroundCommandRunner
2223
import com.stackspot.intellij.commands.git.GitBranch
2324
import com.stackspot.intellij.commands.git.GitConfig
@@ -27,9 +28,20 @@ import java.util.logging.Level
2728
import java.util.logging.Logger
2829

2930
@Service
30-
class GetDocumentationService {
31+
class GetDocumentationService() {
3132

32-
companion object {
33+
private var gitConfigCmd = GitConfig(Constants.Paths.STK_HOME.toString())
34+
private var gitBranchCmd = GitBranch(Constants.Paths.STK_HOME.toString(), arrayOf("--show-current"))
35+
36+
constructor(
37+
gitConfigCmd: GitConfig = GitConfig(Constants.Paths.STK_HOME.toString()),
38+
gitBranchCmd: GitBranch = GitBranch(Constants.Paths.STK_HOME.toString(), arrayOf("--show-current"))
39+
) : this() {
40+
this.gitConfigCmd = gitConfigCmd
41+
this.gitBranchCmd = gitBranchCmd
42+
}
43+
44+
private companion object {
3345
val LOGGER: Logger = Logger.getLogger(GetDocumentationService::class.java.name)
3446
val REMOTE_URL_SSH_REGEX = Regex("(?i)(git@).*?.git")
3547
}
@@ -71,13 +83,14 @@ class GetDocumentationService {
7183
}
7284

7385
private fun getRemoteUrl(stack: Stack): String {
74-
val gitRemoteCmd = GitConfig(stack.location.toPath().toString(), arrayOf("--get", "remote.origin.url"))
75-
gitRemoteCmd.run()
76-
return (gitRemoteCmd.runner as BackgroundCommandRunner).stdout
86+
gitConfigCmd.workingDirectory = stack.location.toPath().toString()
87+
gitConfigCmd.flags = arrayOf("--get", "remote.origin.url")
88+
gitConfigCmd.run()
89+
return (gitConfigCmd.runner as BackgroundCommandRunner).stdout
7790
}
7891

7992
private fun getCurrentBranchName(stack: Stack): String {
80-
val gitBranchCmd = GitBranch(stack, arrayOf("--show-current"))
93+
gitBranchCmd.workingDir = stack.location.toPath().toString()
8194
gitBranchCmd.run()
8295
return (gitBranchCmd.runner as BackgroundCommandRunner).stdout
8396
}

src/main/kotlin/com/stackspot/intellij/services/enums/RepositoryUriGenerator.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ enum class RepositoryUriGenerator(private val domainName: Array<String>? = null)
4141
}
4242
};
4343

44+
abstract fun generateUri(branchName: String): String
45+
4446
companion object {
4547
fun findByName(name: String): RepositoryUriGenerator =
46-
RepositoryUriGenerator.values().find { enum -> enum.name.contains(name, ignoreCase = true) } ?: UNKNOWN
48+
RepositoryUriGenerator.values()
49+
.find { enum -> name.isNotEmpty() && enum.name.contains(name, ignoreCase = true) } ?: UNKNOWN
4750

4851
fun findByDomainName(domainName: String): RepositoryUriGenerator {
4952
var repository: RepositoryUriGenerator = UNKNOWN
@@ -56,6 +59,4 @@ enum class RepositoryUriGenerator(private val domainName: Array<String>? = null)
5659
}
5760
}
5861

59-
abstract fun generateUri(branchName: String): String
60-
6162
}

0 commit comments

Comments
 (0)