aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-04-22 19:12:03 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-04-22 19:12:03 +0200
commitc8d79c2a149153eba15fc7729b2349199dff362f (patch)
tree43926ae1e593ca43f5429e9b3ac56082e70a7e00
parente371c801fed71bb73bc7c027e3de5ad2a6116673 (diff)
fix is_parent on .HEADmaster
-rwxr-xr-xsrc/blueprint10
-rw-r--r--src/lib/path.lua9
2 files changed, 15 insertions, 4 deletions
diff --git a/src/blueprint b/src/blueprint
index 35b9c0e..ed8bc94 100755
--- a/src/blueprint
+++ b/src/blueprint
@@ -21,10 +21,14 @@ local commands = {
local command = commands[arg[1]]
if command then
- local status, ret = pcall(command)
+ if os.getenv('BP_TRACE') == '1' then
+ command()
+ else
+ local status, ret = pcall(command)
- if not status then
- print('error: ' .. ret:gsub('^.+:%d+: (.+)$', '%1'))
+ if not status then
+ print('error: ' .. ret:gsub('^.+:%d+: (.+)$', '%1'))
+ end
end
else
print([[blueprint <command> [options...]
diff --git a/src/lib/path.lua b/src/lib/path.lua
index 925f017..72ea94d 100644
--- a/src/lib/path.lua
+++ b/src/lib/path.lua
@@ -9,6 +9,7 @@ function Path:new(p)
p = p:gsub("^%./", "")
p = p:gsub("/[^/]+/%.%.", "")
p = p:gsub("^[^/]+/%.%./", "")
+ p = p:gsub("^[^/]+/%.%.$", "")
local path = {
segments = p:split('/'),
@@ -34,6 +35,9 @@ function Path:parent()
end
function Path:__tostring()
+ if #self.segments == 0 then
+ return "."
+ end
return (self.is_absolute and "/" or "") .. table.concat(self.segments, "/")
end
@@ -132,8 +136,11 @@ function Path:is_parent_of(child)
end
function Path:relative_to_parent(path)
- if not path:is_parent_of(self) then
+ if #path.segments > 0 and not path:is_parent_of(self) then
+ print('not parent', path, self)
return nil
+ elseif #path.segments == 0 then
+ return Path:new(tostring(self))
end
return Path:new(tostring(self):sub(#tostring(path) + 2))