From 3fd2648558bc078032ae80a641b70a3400948662 Mon Sep 17 00:00:00 2001 From: jchrist Date: Thu, 14 Dec 2023 08:40:38 +0200 Subject: [PATCH] chore(update): Update gradle, intellij and dependencies Update required java version to 17 (requires updating intellij since 2022.2) Update gradle to 8.5 Update intellij gradle plugin and test dependencies to latest versions Add changelog for next release Bump version to 0.8.0 for release Signed-off-by: jchrist --- .github/dependabot.yml | 5 ++ .github/workflows/build.yml | 26 +++++++-- CHANGELOG.md | 4 ++ build.gradle | 47 +++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- .../gitextender/RepositoryUpdater.java | 3 +- .../configuration/ProjectSettingsHandler.java | 18 +++--- .../handlers/AfterSuccessfulMergeHandler.java | 3 +- src/main/resources/META-INF/plugin.xml | 7 ++- .../gr/jchrist/gitextender/AbstractIT.java | 55 ++++++++++++++----- .../gr/jchrist/gitextender/GitTestUtil.java | 43 ++++++--------- .../gitextender/ProjectUpdateITest.java | 33 ++++++----- 12 files changed, 151 insertions(+), 95 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index eecaea3..2cac22b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,6 +4,11 @@ version: 2 updates: - package-ecosystem: "gradle" + directory: "/" + schedule: + interval: "daily" + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" directory: "/" schedule: interval: "daily" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50812a2..2e2e12a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,14 +6,30 @@ jobs: citest: runs-on: ubuntu-latest steps: + # Free GitHub Actions Environment Disk Space + - name: Maximize Build Space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc - name: checkout - uses: actions/checkout@v1 - - name: setup_jdk - uses: actions/setup-java@v1 + uses: actions/checkout@v4 + # Validate wrapper + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1 + - name: Setup Java + uses: actions/setup-java@v4 with: - java-version: 11 + distribution: corretto + java-version: 17 - name: build run: ./gradlew check --stacktrace --info - - uses: codecov/codecov-action@v2 + - uses: codecov/codecov-action@v3 with: token: ${{ secrets.CODECOV_TOKEN }} + - name: Collect Tests Result + if: ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: tests-result + path: ${{ github.workspace }}/build/reports/tests diff --git a/CHANGELOG.md b/CHANGELOG.md index e0bcf7c..d8bf96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog --------- + +## 0.8.0 (2023-12-14) +* Fix no display name for configurable. Closes [#70](https://github.com/JChrist/gitextender/issues/70) + ## 0.7.0 (2021-06-04) * Workaround issue with wrong thread creating the update tree, by disabling showing update tree diff --git a/build.gradle b/build.gradle index 1f0f11b..73db30c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,24 @@ -buildscript { - repositories { - mavenCentral() - jcenter() - } +plugins { + id "java" + id "org.jetbrains.intellij" version "1.16.1" + id "jacoco" } -plugins { - id "org.jetbrains.intellij" version "1.8.1" +repositories { + mavenCentral() + maven { + url = uri("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies") + } } intellij { type = 'IC' - version = "2021.1" -// version = "LATEST-EAP-SNAPSHOT" +// version = "2022.2" + version = "LATEST-EAP-SNAPSHOT" updateSinceUntilBuild = false downloadSources = true //comma separated list of plugins to depend on - plugins = ['git4idea'] + plugins = ['Git4Idea'] pluginName = 'gitextender' } @@ -28,31 +30,36 @@ intellij { }*/ group 'gr.jchrist' -version '0.7.0' +version '0.8.0' -apply plugin: 'java' -sourceCompatibility = '11' -targetCompatibility = '11' +sourceCompatibility = '17' +targetCompatibility = '17' repositories { mavenCentral() } dependencies { - testImplementation 'org.mockito:mockito-core:4.+' + testImplementation 'org.mockito:mockito-core:5.8.0' testImplementation 'junit:junit:4.13.2' - testImplementation 'org.assertj:assertj-core:3.23.1' + testImplementation 'org.assertj:assertj-core:3.24.2' } buildSearchableOptions.enabled=false -apply plugin: 'jacoco' jacocoTestReport { reports { - xml.enabled = true - html.enabled = false + xml.required = true + html.required = false + csv.required = false } } //specify here that jacoco test report should execute after test -test { finalizedBy jacocoTestReport } +test { + finalizedBy jacocoTestReport + jacoco { + includeNoLocationClasses = true + excludes = ["jdk.internal.*"] + } +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 297f2fe..559efb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip diff --git a/src/main/java/gr/jchrist/gitextender/RepositoryUpdater.java b/src/main/java/gr/jchrist/gitextender/RepositoryUpdater.java index 31bbb33..db57299 100644 --- a/src/main/java/gr/jchrist/gitextender/RepositoryUpdater.java +++ b/src/main/java/gr/jchrist/gitextender/RepositoryUpdater.java @@ -1,5 +1,6 @@ package gr.jchrist.gitextender; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -67,7 +68,7 @@ public void updateRepository() { final Project project = repo.getProject(); //find git service - final Git git = ServiceManager.getService(Git.class); + final Git git = ApplicationManager.getApplication().getService(Git.class); final String currBranch = repo.getCurrentBranchName(); if (currBranch == null) { diff --git a/src/main/java/gr/jchrist/gitextender/configuration/ProjectSettingsHandler.java b/src/main/java/gr/jchrist/gitextender/configuration/ProjectSettingsHandler.java index 2a31179..0f0185f 100644 --- a/src/main/java/gr/jchrist/gitextender/configuration/ProjectSettingsHandler.java +++ b/src/main/java/gr/jchrist/gitextender/configuration/ProjectSettingsHandler.java @@ -22,22 +22,19 @@ public ProjectSettingsHandler(@NotNull Project project) { @NotNull public List loadSelectedModules() { - List modules = new ArrayList<>(); - - String[] selectedModules = properties.getValues(SELECTED_MODULES_KEY); - if (selectedModules == null || selectedModules.length == 0) { - return modules; + List selectedModules = properties.getList(SELECTED_MODULES_KEY); + if (selectedModules == null) { + return new ArrayList<>(); } - modules.addAll(Arrays.asList(selectedModules)); - return modules; + return new ArrayList<>(selectedModules); } public void addSelectedModule(@NotNull String module) { List modules = loadSelectedModules(); if (!modules.contains(module)) { modules.add(module); - properties.setValues(SELECTED_MODULES_KEY, modules.toArray(new String[modules.size()])); + properties.setList(SELECTED_MODULES_KEY, modules); } } @@ -48,16 +45,17 @@ public void removeSelectedModule(@NotNull String module) { if (modules.isEmpty()) { clearSelectedModules(); } else { - properties.setValues(SELECTED_MODULES_KEY, modules.toArray(new String[modules.size()])); + properties.setList(SELECTED_MODULES_KEY, modules); } } } public void setSelectedModules(@NotNull List modules) { - properties.setValues(SELECTED_MODULES_KEY, modules.toArray(new String[modules.size()])); + properties.setList(SELECTED_MODULES_KEY, new ArrayList<>(modules)); } public void clearSelectedModules() { + properties.setList(SELECTED_MODULES_KEY, new ArrayList<>()); properties.unsetValue(SELECTED_MODULES_KEY); } diff --git a/src/main/java/gr/jchrist/gitextender/handlers/AfterSuccessfulMergeHandler.java b/src/main/java/gr/jchrist/gitextender/handlers/AfterSuccessfulMergeHandler.java index 0a4fb61..49eb115 100644 --- a/src/main/java/gr/jchrist/gitextender/handlers/AfterSuccessfulMergeHandler.java +++ b/src/main/java/gr/jchrist/gitextender/handlers/AfterSuccessfulMergeHandler.java @@ -2,6 +2,7 @@ import com.intellij.history.Label; import com.intellij.history.LocalHistory; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher; @@ -104,6 +105,6 @@ public UpdateInfoTree generateUpdateInfoTree() { protected void showUpdateTree(final UpdateInfoTree tree) { if (!mergeState.getProject().isOpen() || mergeState.getProject().isDisposed() || tree == null) return; - GuiUtils.invokeLaterIfNeeded(() -> ViewUpdateInfoNotification.focusUpdateInfoTree(mergeState.getProject(), tree), ModalityState.defaultModalityState()); + ApplicationManager.getApplication().invokeLater(() -> ViewUpdateInfoNotification.focusUpdateInfoTree(mergeState.getProject(), tree), ModalityState.defaultModalityState()); } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 9e87305..74ba3d1 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ gr.jchrist.gitextender Git Extender - 0.7.0 + 0.8.0 JChrist +
  • + 0.8.0: Fix no display name for configurable. Closes [#70](https://github.com/JChrist/gitextender/issues/70) +
  • 0.7.0: Workaround issue with wrong thread creating the update tree, by disabling showing update tree
  • @@ -78,7 +81,7 @@ - + com.intellij.modules.lang com.intellij.modules.vcs diff --git a/src/test/java/gr/jchrist/gitextender/AbstractIT.java b/src/test/java/gr/jchrist/gitextender/AbstractIT.java index e2e65bf..f89c2ee 100644 --- a/src/test/java/gr/jchrist/gitextender/AbstractIT.java +++ b/src/test/java/gr/jchrist/gitextender/AbstractIT.java @@ -1,19 +1,22 @@ package gr.jchrist.gitextender; import com.intellij.ide.highlighter.ProjectFileType; -import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.*; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vcs.ProjectLevelVcsManager; +import com.intellij.openapi.vcs.VcsConfiguration; +import com.intellij.openapi.vcs.VcsNotifier; +import com.intellij.openapi.vcs.VcsShowConfirmationOption; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.changes.ChangeListManagerImpl; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.testFramework.EdtTestUtil; import com.intellij.testFramework.HeavyPlatformTestCase; -import com.intellij.testFramework.PlatformTestCase; import com.intellij.testFramework.TestLoggerFactory; import com.intellij.util.ArrayUtil; import git4idea.DialogManager; @@ -21,21 +24,24 @@ import git4idea.GitVcs; import git4idea.commands.Git; import git4idea.config.GitVcsSettings; +import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public abstract class AbstractIT extends HeavyPlatformTestCase { + private static final Logger logger = Logger.getInstance(GitTestUtil.class); + protected File myTestRoot; protected VirtualFile myTestRootFile; protected VirtualFile myProjectRoot; @@ -52,14 +58,10 @@ public abstract class AbstractIT extends HeavyPlatformTestCase { @Rule public TestName testName = new TestName(); - private boolean inited = false; private boolean stopped = false; @Before public final void abstractSetUp() throws Exception { - //if (inited) return; - //inited = true; - //EdtTestUtil.runInEdtAndWait(() -> super.setUp()); myTestRoot = new File(FileUtil.getTempDirectory(), "testRoot"); checkTestRootIsEmpty(myTestRoot); @@ -75,11 +77,11 @@ public final void abstractSetUp() throws Exception { myGitSettings = GitVcsSettings.getInstance(myProject); myGitSettings.getAppSettings().setPathToGit(GitExecutor.PathHolder.getGitExecutable()); - myDialogManager = ServiceManager.getService(DialogManager.class); - myVcsNotifier = ServiceManager.getService(myProject, VcsNotifier.class); + myDialogManager = ApplicationManager.getApplication().getService(DialogManager.class); + myVcsNotifier = myProject.getService(VcsNotifier.class); myGitRepositoryManager = GitUtil.getRepositoryManager(myProject); - myGit = ServiceManager.getService(Git.class); + myGit = ApplicationManager.getApplication().getService(Git.class); myVcs = GitVcs.getInstance(myProject); myVcs.doActivate(); @@ -154,6 +156,20 @@ protected void refresh() { VfsUtil.markDirtyAndRefresh(false, true, false, myTestRootFile); } + public void updateRepos() { + updateRepos(null); + } + + public void updateRepos(GitRepository repository) { + var grm = getGitRepositoryManager(); + runOutOfEdt(() -> { + if (repository != null) { + repository.update(); + } + grm.updateAllRepositories(); + }); + } + private void checkTestRootIsEmpty(File testRoot) { File[] files = testRoot.listFiles(); if (files != null && files.length > 0) { @@ -244,4 +260,17 @@ public DialogManager getDialogManager() { public VcsNotifier getVcsNotifier() { return myVcsNotifier; } + + public static void runOutOfEdt(Runnable r) { + final var latch = new CountDownLatch(1); + ApplicationManager.getApplication().executeOnPooledThread(() -> { + r.run(); + latch.countDown(); + }); + try { + latch.await(10, TimeUnit.SECONDS); + } catch (Exception e) { + logger.warn("error waiting", e); + } + } } diff --git a/src/test/java/gr/jchrist/gitextender/GitTestUtil.java b/src/test/java/gr/jchrist/gitextender/GitTestUtil.java index 40f7f1a..7589732 100644 --- a/src/test/java/gr/jchrist/gitextender/GitTestUtil.java +++ b/src/test/java/gr/jchrist/gitextender/GitTestUtil.java @@ -2,8 +2,6 @@ import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl; @@ -14,16 +12,22 @@ import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; import org.jetbrains.annotations.NotNull; -import org.picocontainer.MutablePicoContainer; import java.io.File; import java.io.IOException; - -import static gr.jchrist.gitextender.GitExecutor.*; +import java.util.concurrent.atomic.AtomicReference; + +import static gr.jchrist.gitextender.GitExecutor.addCommit; +import static gr.jchrist.gitextender.GitExecutor.append; +import static gr.jchrist.gitextender.GitExecutor.cd; +import static gr.jchrist.gitextender.GitExecutor.checkout; +import static gr.jchrist.gitextender.GitExecutor.git; +import static gr.jchrist.gitextender.GitExecutor.last; +import static gr.jchrist.gitextender.GitExecutor.push; +import static gr.jchrist.gitextender.GitExecutor.tac; import static org.assertj.core.api.Assertions.assertThat; public class GitTestUtil { - public static void cloneRepo(@NotNull String source, @NotNull String destination, boolean bare) { cd(source); git("clone "+(bare ? "--bare " : "") + "-- . " + destination); @@ -68,7 +72,12 @@ public static GitRepository registerRepo(Project project, String root) { assertThat(vcsManager.getAllVcsRoots().length).isNotZero(); GitRepositoryManager grm = GitUtil.getRepositoryManager(project); - GitRepository repository = grm.getRepositoryForRoot(file); + AtomicReference ref = new AtomicReference<>(); + AbstractIT.runOutOfEdt(() -> { + var repository = grm.getRepositoryForRoot(file); + ref.set(repository); + }); + var repository = ref.get(); assertThat(repository).as("Couldn't find repository for root " + root).isNotNull(); return repository; } @@ -107,24 +116,4 @@ public static String cleanupForAssertion(@NotNull String content) { private static String tos(@NotNull Notification notification) { return notification.getTitle() + "|" + notification.getContent(); } - - @SuppressWarnings("unchecked") - @NotNull - public static T overrideProjectComponent(@NotNull Project project, Class serviceInterface, Class serviceImplementation) { - String key = serviceInterface.getName(); - MutablePicoContainer picoContainer = (MutablePicoContainer) project.getPicoContainer(); - picoContainer.unregisterComponent(key); - picoContainer.registerComponentImplementation(key, serviceImplementation); - return (T) project.getComponent(serviceInterface); - } - - @SuppressWarnings("unchecked") - @NotNull - public static T overrideService(Class serviceInterface, Class serviceImplementation) { - String key = serviceInterface.getName(); - MutablePicoContainer picoContainer = (MutablePicoContainer) ApplicationManager.getApplication().getPicoContainer(); - picoContainer.unregisterComponent(key); - picoContainer.registerComponentImplementation(key, serviceImplementation); - return (T) ServiceManager.getService(serviceInterface); - } } diff --git a/src/test/java/gr/jchrist/gitextender/ProjectUpdateITest.java b/src/test/java/gr/jchrist/gitextender/ProjectUpdateITest.java index c411f8e..de01800 100644 --- a/src/test/java/gr/jchrist/gitextender/ProjectUpdateITest.java +++ b/src/test/java/gr/jchrist/gitextender/ProjectUpdateITest.java @@ -4,6 +4,8 @@ import com.intellij.notification.NotificationType; import com.intellij.notification.Notifications; import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.WriteCommandAction; @@ -15,6 +17,7 @@ import git4idea.repo.GitRepository; import gr.jchrist.gitextender.configuration.GitExtenderSettings; import gr.jchrist.gitextender.configuration.GitExtenderSettingsHandler; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.After; import org.junit.Before; @@ -61,17 +64,19 @@ public final void before() throws Exception { logger.info("creating test remote in directory: " + remoteRepoPath+" with access (non-bare) in:"+remoteRepoAccessPath); - repository = GitTestUtil.createRemoteRepositoryAndCloneToLocal(super.getProject(), super.getProjectPath(), - remoteRepoPath, remoteRepoAccessPath); - repository.update(); - super.getGitRepositoryManager().updateAllRepositories(); + repository = GitTestUtil.createRemoteRepositoryAndCloneToLocal(super.getProject(), super.getProjectPath(), remoteRepoPath, remoteRepoAccessPath); + final var grm = super.getGitRepositoryManager(); + runOutOfEdt(() -> { + repository.update(); + grm.updateAllRepositories(); + }); - logger.info("Starting up with repos: " + super.getGitRepositoryManager().getRepositories() + - " Branch track infos: "+ super.getGitRepositoryManager().getRepositories().get(0).getBranchTrackInfos()); + logger.info("Starting up with repos: " + grm.getRepositories() + + " Branch track infos: "+ grm.getRepositories().get(0).getBranchTrackInfos()); updater = new GitExtenderUpdateAll(); - event = AnActionEvent.createFromAnAction(updater, null, "somewhere", - new TestDataProvider(super.getProject())); + final var tdp = new TestDataProvider(super.getProject()); + event = AnActionEvent.createFromAnAction(updater, null, "somewhere", tdp::getData); Application app = ApplicationManager.getApplication(); logger.info("initialized app: "+app); @@ -150,8 +155,8 @@ public void updateLocalRemoteDivergedOnlyFFNotUpdated() throws Exception { //not pushing this since it would get rejected (remote is 1 commit ahead) checkout(MAIN_BRANCH_NAME); - repository.update(); - super.getGitRepositoryManager().updateAllRepositories(); + final var grm = getGitRepositoryManager(); + updateRepos(repository); runUpdate(); @@ -180,8 +185,7 @@ public void updateLocalRemoteDivergedSimpleMergeUpdated() throws Exception { //not pushing this since it would get rejected (remote is 1 commit ahead) checkout(MAIN_BRANCH_NAME); - repository.update(); - super.getGitRepositoryManager().updateAllRepositories(); + updateRepos(repository); //enable merge/abort settings.setAttemptMergeAbort(true); @@ -218,8 +222,7 @@ public void updateLocalRemoteConflictOnFileAborted() throws Exception { //not pushing this since it would get rejected (remote is 1 commit ahead) checkout(MAIN_BRANCH_NAME); - repository.update(); - super.getGitRepositoryManager().updateAllRepositories(); + updateRepos(repository); //enable merge/abort settings.setAttemptMergeAbort(true); @@ -251,7 +254,7 @@ public void updateWithPrunedRemotesLocalDeleted() { checkout("develop"); git("pull"); - super.getGitRepositoryManager().updateAllRepositories(); + updateRepos(); //now delete branch on remote cd(remoteRepoAccessPath);