aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2024-12-13 14:14:11 +0100
committerGitHub Enterprise <[email protected]>2024-12-13 14:14:11 +0100
commit301f3c1b1bfebf9722fa7a0df6877f9b593ba290 (patch)
treee07eab16bee30c121a5e83f17fbf6bcef312b358 /src
parent5.5.16-pre3 (diff)
downloadzen-301f3c1b1bfebf9722fa7a0df6877f9b593ba290.tar.xz
zen-301f3c1b1bfebf9722fa7a0df6877f9b593ba290.zip
fix trailing path separator in workspace commands (#265)
Diffstat (limited to 'src')
-rw-r--r--src/zen/cmds/workspaces_cmd.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp
index b5d9af1be..2c8fe43f6 100644
--- a/src/zen/cmds/workspaces_cmd.cpp
+++ b/src/zen/cmds/workspaces_cmd.cpp
@@ -20,6 +20,16 @@
namespace zen {
namespace {
+ static void RemoveTrailingPathSeparator(std::filesystem::path& Path)
+ {
+ std::u8string PathString = Path.u8string();
+ if (PathString.ends_with(std::filesystem::path::preferred_separator))
+ {
+ PathString.pop_back();
+ Path = std::filesystem::path(PathString);
+ }
+ }
+
void ShowShare(const Workspaces::WorkspaceShareConfiguration& Share, const Oid& WorkspaceId, std::string_view Prefix)
{
ZEN_CONSOLE("{}Id: {}", Prefix, Share.Id);
@@ -136,6 +146,8 @@ WorkspaceCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv)
throw zen::OptionParseException(fmt::format("path is required\n{}", m_CreateOptions.help()));
}
+ RemoveTrailingPathSeparator(m_Path);
+
if (m_Id.empty())
{
m_Id = Workspaces::PathToId(m_Path).ToString();
@@ -403,6 +415,7 @@ WorkspaceShareCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char**
}
else
{
+ RemoveTrailingPathSeparator(m_WorkspaceRoot);
if (m_WorkspaceId.empty())
{
m_WorkspaceId = Workspaces::PathToId(m_WorkspaceRoot).ToString();
@@ -425,6 +438,8 @@ WorkspaceShareCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char**
}
}
+ RemoveTrailingPathSeparator(m_SharePath);
+
if (m_ShareId.empty())
{
m_ShareId = Workspaces::PathToId(m_SharePath).ToString();