Skip to content

Conversation

mattmikolay
Copy link
Contributor

@mattmikolay mattmikolay commented Oct 9, 2025

Description

This PR updates the knock branch switch command so that when a .knock_branch file is not found, we prompt the user to create one automatically. We’ll look for an existing .gitignore file and create the .knock_branch file sibling to it. The directory containing .gitignore is our best guess for the root of the user’s project.

I also updated knock branch exit so that instead of deleting the .knock_branch file, it writes an empty string to it. This feels less intrusive than constantly deleting and re-creating .knock_branch.

Tasks

KNO-10034

Loom demo

https://www.loom.com/share/aaa825700da144ab8f6ea08208870860?sid=455ace12-9bf9-4d68-8137-93a0c4f388fa

Copy link

linear bot commented Oct 9, 2025

Copy link
Contributor Author

mattmikolay commented Oct 9, 2025

@mattmikolay mattmikolay changed the title Add force flag to switch command feat(KNO-10034): create .knock_branch file when it does not exist Oct 9, 2025
@mattmikolay mattmikolay marked this pull request as ready for review October 10, 2025 13:52
Copy link
Contributor

@connorlindsey connorlindsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good!

*
* @returns the path to the project root directory
*/
export const findProjectRoot = async (): Promise<string> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious on the heuristic of looking for the .gitignore. I think it makes sense for when you're in your project and executing a command from a sub-folder but I wonder if it may have unintended consequences, or if we should place other limits, like only looking up N levels. Just feels like an early optimization but I'm not completely opposed to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I just updated findProjectRoot to add an additional restriction: we’ll stop searching for .gitignore when we find a .git directory, since that is most likely the repository root.

@mattmikolay mattmikolay force-pushed the mattmik-kno-10048-cli-add-branch-exit-command branch from 0feff27 to 6ccacee Compare October 13, 2025 13:16
@mattmikolay mattmikolay force-pushed the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch from de49ee1 to 2363bcd Compare October 13, 2025 13:16
@mattmikolay mattmikolay changed the title feat(KNO-10034): create .knock_branch file when it does not exist feat(KNO-10034): create .knockbranch file when it does not exist Oct 13, 2025
@mattmikolay mattmikolay force-pushed the mattmik-kno-10048-cli-add-branch-exit-command branch from 6ccacee to f04186a Compare October 13, 2025 13:41
@mattmikolay mattmikolay force-pushed the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch 2 times, most recently from 4249415 to 54053d6 Compare October 13, 2025 13:44
@mattmikolay mattmikolay force-pushed the mattmik-kno-10048-cli-add-branch-exit-command branch 2 times, most recently from 2575171 to b349bb1 Compare October 13, 2025 13:58
@mattmikolay mattmikolay changed the base branch from mattmik-kno-10048-cli-add-branch-exit-command to graphite-base/624 October 13, 2025 14:03
@mattmikolay mattmikolay force-pushed the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch from 54053d6 to 458225d Compare October 13, 2025 14:03
@graphite-app graphite-app bot changed the base branch from graphite-base/624 to main October 13, 2025 14:04
@mattmikolay mattmikolay force-pushed the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch from 458225d to 506c585 Compare October 13, 2025 14:04
@mattmikolay mattmikolay force-pushed the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch from 506c585 to 811cb3b Compare October 13, 2025 15:35
Copy link
Contributor Author

mattmikolay commented Oct 13, 2025

Merge activity

  • Oct 13, 3:48 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 13, 3:48 PM UTC: @mattmikolay merged this pull request with Graphite.

@mattmikolay mattmikolay merged commit dc9244a into main Oct 13, 2025
8 checks passed
@mattmikolay mattmikolay deleted the mattmik-kno-10034-cli-create-knock_branch-file-when-it-does-not-exist branch October 13, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants