-
Notifications
You must be signed in to change notification settings - Fork 266
feat: Add ability to configure the git worktree path via the configuration file #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cc @bjcoombs some feature requests that you had that I also wanted. @mufeez-amjad & @jayshrivastava I cannot mark reviewers but would one of you be willing to give this a review and let me know what it would take to get something like this merged? |
Hi @mufeez-amjad is there anything I can do to help push this along? |
@nbperry do you mind rebasing your changes on the latest |
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
@mufeez-amjad signed the CLA so we should be good on that side of things. |
Checking in again @mufeez-amjad, incase there is anything I can do to help push this along. |
@@ -57,6 +63,12 @@ func (g *GitWorktree) SetupNewWorktree() error { | |||
return fmt.Errorf("failed to create worktrees directory: %w", err) | |||
} | |||
|
|||
// Ensure the parent directory of the worktree path exists | |||
worktreeParent := filepath.Dir(g.worktreePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain why this is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well git worktree add
requires a directory to create worktree. Since the SetupNewWorktree
and SetupFromExistingBranch
are separately called in the Setup
we need do do this in both of them.
So this checks for the directory and creates it if it does not exist to then be able to perform the git worktree add
.
} | ||
|
||
// parseWorktreePattern substitutes variables in the pattern with actual values | ||
func parseWorktreePattern(pattern string, vars PatternVariables) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can usetext/template
to do this replacing operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I will update to this approach,I am pretty new to go so still learning alot of things 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated via 5908ac6
// WorktreePattern is the pattern used to determine worktree location. | ||
// Supports variables: {repo_root}, {repo_name}, {issue_number}, {title}, {timestamp} | ||
// Example: "{repo_root}/worktree/{issue_number}-{title}" | ||
WorktreePattern string `json:"worktree_pattern"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to make this apply to the branch name too. I think it's good for branch names to be 1:1 with worktree paths.
Maybe we can call it WorkStreamPattern
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you thinking the branch name would be another pattern we include?
This resolves #86
This enables users to set via
worktree_pattern
in their config file where they want their worktrees to be created. Please bear with me around any code things as this is the first time I have ever written Go. So if there are better ways to do things let me know. I also had claude code help me a bit with this since I am not super familiar with Go and they could have steered me wrong as well. Any suggestions would be greatly appreciated.Example demos below.
Below is an example using a more central worktree location
"worktree_pattern": "~/repos/worktree/{issue_number}-{title}"
Screen.Recording.2025-06-11.at.11.35.24.AM.mov
Below is an example using
"worktree_pattern": "{repo_root}/worktree/{issue_number}-{title}"
in config fileScreen.Recording.2025-06-11.at.11.30.39.AM.mov
I believe this sort of handles the idea of #90 as well I suspect. I could be misunderstanding the full Idea of that issue so let me know if not.