Skip to content

Wrong template values when is using wt switch pr:<number> #3934

Description

@robsonpeixoto

Wrong template values when is using wt switch pr:<number>.

As you can se on the output below, the worktree_path is being the /tmp/wt/worktrunk and should be /tmp/wt/worktrunk.feat-issue-3922-list-sort and the branch should not be pr:3933.

Maybe the hooks should wait for the step of "translate" the PR number in a branch name.

❯ wt switch pr:3933 --verbose
○ user:mise-env source
  set -x
  mise -C "{{ worktree_path }}" set -E local COMPOSE_PROJECT_NAME={{ primary_worktree_path | basename | lower }}
○ user:mise-env result
  set -x
  mise -C "/tmp/wt/worktrunk" set -E local COMPOSE_PROJECT_NAME=worktrunk
○ pre-switch template variables:
  branch                = pr:3933
  worktree_path         = /tmp/wt/worktrunk
  worktree_name         = worktrunk
  commit                = (unset)
  short_commit          = (unset)
  upstream              = (unset)
  base                  = main
  base_worktree_path    = /tmp/wt/worktrunk
  target                = pr:3933
  target_worktree_path  = (unset)
  pr_number             = (unset)
  pr_url                = (unset)
  repo                  = worktrunk
  repo_path             = /tmp/wt/worktrunk
  owner                 = max-sixty
  remote_repo           = worktrunk
  primary_worktree_path = /tmp/wt/worktrunk
  default_branch        = main
  remote                = origin
  remote_url            = git@github.com:max-sixty/worktrunk.git
  cwd                   = /tmp/wt/worktrunk
  hook_type             = pre-switch
  hook_name             = mise-env
◎ Running pre-switch user:mise-env
  set -x
  mise -C "/tmp/wt/worktrunk" set -E local COMPOSE_PROJECT_NAME=worktrunk
+ mise -C /tmp/wt/worktrunk set -E local COMPOSE_PROJECT_NAME=worktrunk
◎ Fetching PR #3933...
  feat(list): add `[list] sort` for configurable row order (#3933)
  by @worktrunk-bot · open · feat/issue-3922-list-sort · https://github.com/max-sixty/worktrunk/pull/3933
◎ Fetching feat/issue-3922-list-sort from origin...
○ worktree-path source
  {{ repo_path }}/../{{ repo }}.{{ branch | sanitize }}
○ worktree-path result
  /tmp/wt/worktrunk/../worktrunk.feat-issue-3922-list-sort
○ user:mise-trust source
  set -x
  if mise trust --show -C {{ primary_worktree_path }} 2>/dev/null | grep -q ': trusted'; then
    mise trust -C "{{ worktree_path }}"
  fi
○ user:mise-trust result
  set -x
  if mise trust --show -C /tmp/wt/worktrunk 2>/dev/null | grep -q ': trusted'; then
    mise trust -C "/tmp/wt/worktrunk.feat-issue-3922-list-sort"
  fi
○ pre-start template variables:
  branch                = feat/issue-3922-list-sort
  worktree_path         = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  worktree_name         = worktrunk.feat-issue-3922-list-sort
  commit                = fc63bae65de50f2ee38b5948821da9ee6fde2820
  short_commit          = fc63bae65
  upstream              = origin/feat/issue-3922-list-sort
  base                  = (unset)
  base_worktree_path    = (unset)
  target                = feat/issue-3922-list-sort
  target_worktree_path  = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  pr_number             = (unset)
  pr_url                = (unset)
  repo                  = worktrunk
  repo_path             = /tmp/wt/worktrunk
  owner                 = max-sixty
  remote_repo           = worktrunk
  primary_worktree_path = /tmp/wt/worktrunk
  default_branch        = main
  remote                = origin
  remote_url            = git@github.com:max-sixty/worktrunk.git
  cwd                   = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  hook_type             = pre-start
  hook_name             = mise-trust
◎ Running pre-start user:mise-trust
  set -x
  if mise trust --show -C /tmp/wt/worktrunk 2>/dev/null | grep -q ': trusted'; then
    mise trust -C "/tmp/wt/worktrunk.feat-issue-3922-list-sort"
  fi
+ mise trust --show -C /tmp/wt/worktrunk
+ grep -q : trusted
+ mise trust -C /tmp/wt/worktrunk.feat-issue-3922-list-sort
mise WARN  No untrusted config files found.
✓ Created worktree for feat/issue-3922-list-sort @ /tmp/wt/worktrunk.feat-issue-3922-list-sort
○ post-switch template variables:
  branch                = feat/issue-3922-list-sort
  worktree_path         = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  worktree_name         = worktrunk.feat-issue-3922-list-sort
  commit                = fc63bae65de50f2ee38b5948821da9ee6fde2820
  short_commit          = fc63bae65
  upstream              = origin/feat/issue-3922-list-sort
  base                  = (unset)
  base_worktree_path    = (unset)
  target                = feat/issue-3922-list-sort
  target_worktree_path  = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  pr_number             = (unset)
  pr_url                = (unset)
  repo                  = worktrunk
  repo_path             = /tmp/wt/worktrunk
  owner                 = max-sixty
  remote_repo           = worktrunk
  primary_worktree_path = /tmp/wt/worktrunk
  default_branch        = main
  remote                = origin
  remote_url            = git@github.com:max-sixty/worktrunk.git
  cwd                   = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  hook_type             = post-switch
  hook_name             = herdr
○ post-start template variables:
  branch                = feat/issue-3922-list-sort
  worktree_path         = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  worktree_name         = worktrunk.feat-issue-3922-list-sort
  commit                = fc63bae65de50f2ee38b5948821da9ee6fde2820
  short_commit          = fc63bae65
  upstream              = origin/feat/issue-3922-list-sort
  base                  = (unset)
  base_worktree_path    = (unset)
  target                = feat/issue-3922-list-sort
  target_worktree_path  = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  pr_number             = (unset)
  pr_url                = (unset)
  repo                  = worktrunk
  repo_path             = /tmp/wt/worktrunk
  owner                 = max-sixty
  remote_repo           = worktrunk
  primary_worktree_path = /tmp/wt/worktrunk
  default_branch        = main
  remote                = origin
  remote_url            = git@github.com:max-sixty/worktrunk.git
  cwd                   = /tmp/wt/worktrunk.feat-issue-3922-list-sort
  hook_type             = post-start
  hook_name             = deps
◎ Running post-switch: herdr (user); post-start: deps & assets, docs-install, docs (project)
❯

Version used:

❯ wt --version
wt v0.75.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions