• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 16117325700

07 Jul 2025 12:45PM UTC coverage: 68.446% (+0.5%) from 67.911%
16117325700

push

github

web-flow
#742: Show warning when git repo name does not meet name convention. (#1375)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>

3286 of 5202 branches covered (63.17%)

Branch coverage included in aggregate %.

8406 of 11880 relevant lines covered (70.76%)

3.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.0
cli/src/main/java/com/devonfw/tools/ide/commandlet/CreateCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.function.Predicate;
6

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.git.GitUrl;
9
import com.devonfw.tools.ide.io.FileAccess;
10
import com.devonfw.tools.ide.property.FlagProperty;
11
import com.devonfw.tools.ide.property.StringProperty;
12
import com.devonfw.tools.ide.version.IdeVersion;
13

14
/**
15
 * {@link Commandlet} to create a new IDEasy instance
16
 */
17
public class CreateCommandlet extends AbstractUpdateCommandlet {
18

19
  /** {@link StringProperty} for the name of the new project */
20
  public final StringProperty newProject;
21

22
  /** {@link FlagProperty} for creating a project with settings inside a code repository */
23
  public final FlagProperty codeRepositoryFlag;
24

25
  /**
26
   * The constructor.
27
   *
28
   * @param context the {@link IdeContext}.
29
   */
30
  public CreateCommandlet(IdeContext context) {
31

32
    super(context);
3✔
33
    this.newProject = add(new StringProperty("", true, "project"));
11✔
34
    this.codeRepositoryFlag = add(new FlagProperty("--code"));
9✔
35
    add(this.settingsRepo);
5✔
36
  }
1✔
37

38
  @Override
39
  public String getName() {
40

41
    return "create";
2✔
42
  }
43

44
  @Override
45
  public boolean isIdeHomeRequired() {
46

47
    return false;
2✔
48
  }
49

50
  @Override
51
  public void run() {
52

53
    String newProjectName = this.newProject.getValue();
5✔
54
    Path newProjectPath = this.context.getIdeRoot().resolve(newProjectName);
6✔
55

56
    this.context.info("Creating new IDEasy project in {}", newProjectPath);
10✔
57
    if (!this.context.getFileAccess().isEmptyDir(newProjectPath)) {
6!
58
      this.context.askToContinue("Directory " + newProjectPath + " already exists. Do you want to continue?");
×
59
    } else {
60
      this.context.getFileAccess().mkdirs(newProjectPath);
5✔
61
    }
62

63
    initializeProject(newProjectPath);
3✔
64
    this.context.setIdeHome(newProjectPath);
4✔
65
    this.context.verifyIdeMinVersion(true);
4✔
66
    super.run();
2✔
67
    this.context.verifyIdeMinVersion(true);
4✔
68
    this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION));
8✔
69
    this.context.success("Successfully created new project '{}'.", newProjectName);
10✔
70

71
    logWelcomeMessage(newProjectPath);
3✔
72
  }
1✔
73

74
  private void initializeProject(Path newInstancePath) {
75

76
    FileAccess fileAccess = this.context.getFileAccess();
4✔
77
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_SOFTWARE));
5✔
78
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_PLUGINS));
5✔
79
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN));
7✔
80
  }
1✔
81

82
  @Override
83
  protected void processRepository() {
84
    RepositoryStrategy repositoryStrategy = new SettingsRepositoryStrategy();
4✔
85
    if (isCodeRepository()) {
3✔
86
      repositoryStrategy = new CodeRepositoryStrategy();
4✔
87
    }
88

89
    processRepositoryUsingStrategy(repositoryStrategy);
3✔
90
  }
1✔
91

92
  @Override
93
  protected boolean isCodeRepository() {
94
    return this.codeRepositoryFlag.isTrue();
4✔
95
  }
96

97
  private void logWelcomeMessage(Path newProjectPath) {
98
    GitUrl gitUrl = GitUrl.of(newProjectPath.toString());
4✔
99
    Path codeRepoPath = this.context.getWorkspacePath().resolve(gitUrl.getProjectName());
7✔
100
    Path settingsFolder = codeRepoPath.resolve(IdeContext.FOLDER_SETTINGS);
4✔
101
    if (Files.exists(settingsFolder)) {
5!
102
      Predicate<Path> welcomePredicate = path -> String.valueOf(path.getFileName()).startsWith("welcome.");
×
103
      Path welcomeFilePath = this.context.getFileAccess().findFirst(settingsFolder, welcomePredicate, false);
×
104
      if (welcomeFilePath != null) {
×
105
        this.context.info(this.context.getFileAccess().readFileContent(welcomeFilePath));
×
106
      }
107
    }
108
  }
1✔
109
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc