Skip to content

Commit

Permalink
Fix(#28847) CLI: push command no executing properly (#29061)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Updated `PushMixin.path()` to ensure correct absolute path resolution.

### Screenshots

![screen-recording-cli-push-command-relative-path](https://github.com/dotCMS/core/assets/77643678/7573f4ad-40cc-4ad2-a9e4-ef668e37f625)

This PR fixes: #28847
  • Loading branch information
valentinogiardino authored Jul 2, 2024
1 parent 884e181 commit 806d78a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Path path() {
if (null == pushPath) {
return Path.of("").toAbsolutePath();
}
return pushPath.toPath();
return pushPath.toPath().normalize().toAbsolutePath();
}

public boolean isWatchMode(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,38 @@ void testSimplePush() throws IOException {
}
}

/**
* Given scenario: A push command is executed using a relative path.
* Expected result: The command should find the folder to push and complete successfully with an exit code 0 (OK).
* @throws IOException
*/
@Test
void testPushWithRelativePath() throws IOException {

// Create a temporal folder for the push
var tempFolder = createTempFolder();
// And a workspace for it
workspaceManager.getOrCreate(tempFolder);

// Get the relative path of the temporal folder
var relativePath = Path.of("").toAbsolutePath().relativize(tempFolder.toAbsolutePath());

try {
final CommandLine commandLine = createCommand();
final StringWriter writer = new StringWriter();
try (PrintWriter out = new PrintWriter(writer)) {
commandLine.setOut(out);
final int status = commandLine.execute(PushCommand.NAME,
relativePath.toString(), "--dry-run");
Assertions.assertEquals(CommandLine.ExitCode.OK, status);
}
} finally {
deleteTempDirectory(tempFolder);
}
}



/**
* This test checks for a situation where an incorrect option is passed to the push command.
*
Expand Down

0 comments on commit 806d78a

Please sign in to comment.