key and API address fall back to the person's secrets file; a non-git folder becomes a local_path project

This commit is contained in:
Sam
2026-11-12 17:19:37 +11:00
parent 3043e9dec1
commit 55085ba40a
11 changed files with 766 additions and 15 deletions

View File

@@ -74,19 +74,33 @@ def create_project(name, folder, dry):
Adopting a folder that Paperclip has never heard of needed two steps before:
make the project in the browser, then run this command. One command is enough.
"""
# A folder that is a git repository gets a branch per task in its own
# worktree. A folder that is not cannot: asking for a worktree would create
# a project whose every run fails. Those keep the folder in place instead.
is_repo = subprocess.run(["git", "-C", folder, "rev-parse", "--is-inside-work-tree"],
capture_output=True, text=True, timeout=30).stdout.strip() == "true"
body = {
"name": name,
"description": "Adopted from %s by bin/office." % folder,
"status": "backlog",
"workspace": {"name": name, "sourceType": "git_repo", "cwd": folder, "isPrimary": True},
"executionWorkspacePolicy": {
"workspace": {
"name": name,
"sourceType": "git_repo" if is_repo else "local_path",
"cwd": folder,
"isPrimary": True,
},
}
if is_repo:
body["executionWorkspacePolicy"] = {
"enabled": True,
"defaultMode": "isolated_workspace",
"allowIssueOverride": True,
"workspaceStrategy": {"type": "git_worktree", "baseRef": "main",
"branchTemplate": "{{issue.identifier}}-{{slug}}"},
},
}
}
else:
h.say(" not a git repository: the project keeps the folder in place,")
h.say(" so a task changes these files directly. No branch, no worktree.")
if dry:
h.say("would create Paperclip project %r for %s" % (name, folder))
return "(dry run)"