-
Notifications
You must be signed in to change notification settings - Fork 87
#1695: Clone settings to temporary directory, analyse, and then move (taken over) #2249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
laim2003
wants to merge
41
commits into
devonfw:main
from
laim2003:feature/1695-clone-settings-to-temp-dir-for-verification
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a122556
WIP Commit
areinicke c497948
Update logic
areinicke 54a1fed
Removed --code option & Added further functionality
areinicke 90e43e7
Fix tests
areinicke 5dba7b5
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
areinicke aa751ff
Update comments
areinicke b19c6eb
Merge branch 'feature/1695-clone-settings-to-temp-dir-for-verificatio…
areinicke 3e936dc
formatting cleanup
areinicke 9bee5f1
Minor code refactor
areinicke 29f6d1f
Update comments
areinicke 8b69339
Update changelog
areinicke d1bfbf5
Add test case for invalid repository
areinicke 64f1220
Replace hard coded variables
areinicke 462d6d5
Fix tests
areinicke 373fc19
Apply suggestion from @satorus
areinicke 2552b4d
Move long if checks to own functions
areinicke d32fc4b
changed variable name to adhere to coding conventions
areinicke 154ff6c
renamed method to follow coding conventions
areinicke 6ce1e46
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
hohwille fcc2a0b
Step 1 Refactor
areinicke 900c0f2
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
hohwille 45d35be
Finish Step 1 Refactor
areinicke 9cfd047
Merge branch 'feature/1695-clone-settings-to-temp-dir-for-verificatio…
areinicke 0e82a26
Fixed temp location not being fully empty after projectr creation
areinicke 777b997
Removed references to --code option in project creation
areinicke b5e23a7
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
areinicke 36018b1
Remove ProjectNameConvention reference
areinicke 94c6511
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
hohwille 6320067
#1695: applied suggestions by @hohwille from original PR #1878
laim2003 6bf858a
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
laim2003 1c92338
#1695: added check for potential folder colision in CreateCommandlet
laim2003 43ac0f2
#1695: adapted tests to new project health checks
laim2003 351e43a
#1695: merged orginal changes by @areinicke into GitContextMock
laim2003 f413ed3
#1695: maven spotless plugin applied
laim2003 302a10e
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
laim2003 9914c70
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
laim2003 97a2429
#1695: extracted code/settings repo detection into utility class
laim2003 5cbce33
#1695: moved analyzeProject and moveProject into AbstractUpdateComman…
laim2003 1fd5d8a
#1695: removed redundant directory existence check
laim2003 36ee9ed
Merge branch 'main' into feature/1695-clone-settings-to-temp-dir-for-…
laim2003 4a66201
Merge remote-tracking branch 'origin/feature/1695-clone-settings-to-t…
laim2003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,10 +7,10 @@ | |
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.devonfw.tools.ide.cli.CliException; | ||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.io.FileAccess; | ||
| import com.devonfw.tools.ide.log.IdeLogLevel; | ||
| import com.devonfw.tools.ide.property.FlagProperty; | ||
| import com.devonfw.tools.ide.property.StringProperty; | ||
| import com.devonfw.tools.ide.version.IdeVersion; | ||
|
|
||
|
|
@@ -24,9 +24,6 @@ public class CreateCommandlet extends AbstractUpdateCommandlet { | |
| /** {@link StringProperty} for the name of the new project */ | ||
| public final StringProperty newProject; | ||
|
|
||
| /** {@link FlagProperty} for creating a project with settings inside a code repository */ | ||
| public final FlagProperty codeRepositoryFlag; | ||
|
|
||
| /** | ||
| * The constructor. | ||
| * | ||
|
|
@@ -36,7 +33,6 @@ public CreateCommandlet(IdeContext context) { | |
|
|
||
| super(context); | ||
| this.newProject = add(new StringProperty("", true, "project")); | ||
| this.codeRepositoryFlag = add(new FlagProperty("--code")); | ||
| add(this.settingsRepo); | ||
| } | ||
|
|
||
|
|
@@ -57,16 +53,17 @@ protected void doRun() { | |
|
|
||
| String newProjectName = this.newProject.getValue(); | ||
| Path newProjectPath = this.context.getIdeRoot().resolve(newProjectName); | ||
| Path tempProjectPath = this.context.getTempPath().resolve(IdeContext.FOLDER_PROJECTS).resolve(newProjectName); | ||
|
|
||
| LOG.info("Creating new IDEasy project in {}", newProjectPath); | ||
| if (!this.context.getFileAccess().isEmptyDir(newProjectPath)) { | ||
| this.context.askToContinue("Directory {} already exists. Do you want to continue?", newProjectPath); | ||
| } else { | ||
| this.context.getFileAccess().mkdirs(newProjectPath); | ||
| throw new CliException( | ||
| String.format("Project directory already exists in: %s. As the project already exists, try calling 'ide update'.", | ||
| newProjectPath)); | ||
| } | ||
|
|
||
| initializeProject(newProjectPath); | ||
| this.context.setIdeHome(newProjectPath); | ||
| initializeProject(tempProjectPath); | ||
| this.context.setIdeHome(tempProjectPath); | ||
| super.doRun(); | ||
| this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I would expect the move from |
||
| IdeLogLevel.SUCCESS.log(LOG, "Successfully created new project '{}'.", newProjectName); | ||
|
|
@@ -82,15 +79,10 @@ private void initializeProject(Path newInstancePath) { | |
| fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN)); | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean isCodeRepository() { | ||
| return this.codeRepositoryFlag.isTrue(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getStepMessage() { | ||
|
|
||
| return "Create (clone) " + (isCodeRepository() ? "code" : "settings") + " repository"; | ||
| return "Create (Clone) repository"; | ||
| } | ||
|
|
||
| private void logWelcomeMessage() { | ||
|
|
||
33 changes: 33 additions & 0 deletions
33
cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.devonfw.tools.ide.git.repository; | ||
|
|
||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
|
|
||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.environment.EnvironmentVariables; | ||
|
|
||
| /// Utility class for IDEasy settings/code repositories | ||
| public class RepositoryUtil { | ||
|
|
||
| /** | ||
| * Checks whether te given repository is a settings repository by checking for the presence of ide.properties or devon.properties on the top level. | ||
| * | ||
| * @param repositoryPath - The path of the repository to be checked. | ||
| * @return true if the repo in the given path is a settings repository | ||
| */ | ||
| public static boolean isSettingsRepository(Path repositoryPath) { | ||
| return Files.exists(repositoryPath.resolve(EnvironmentVariables.DEFAULT_PROPERTIES)) || Files.exists( | ||
| repositoryPath.resolve(EnvironmentVariables.LEGACY_PROPERTIES)); | ||
| } | ||
|
|
||
| /** | ||
| * Checks whether te given repository is a code repository by checking for the presence of ide.properties or devon.properties within a settings folder on the | ||
| * top level. | ||
| * | ||
| * @param repositoryPath - The path of the repository to be checked. | ||
| * @return true if the repo in the given path is a code repository | ||
| */ | ||
| public static boolean isCodeRepository(Path repositoryPath) { | ||
| return isSettingsRepository(repositoryPath.resolve(IdeContext.FOLDER_SETTINGS)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move up