Skip to content

Commit

Permalink
feat: adds branch command to unset upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
cdloh committed Aug 29, 2024
1 parent 75c0a6a commit 70aaeb1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,14 @@
{ "key": "setting.git_savvy.branch_view", "operator": "equal", "operand": true }
]
},
{
"keys": ["u"],
"command": "gs_branches_unset_upstream",
"context": [
{ "key": "setting.command_mode", "operator": "equal", "operand": false },
{ "key": "setting.git_savvy.branch_view", "operator": "equal", "operand": true }
]
},


////////////////
Expand Down
23 changes: 22 additions & 1 deletion core/interfaces/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"gs_branches_navigate_to_active_branch",
"gs_branches_log",
"gs_branches_log_graph",
"gs_branches_unset_upstream",
)


Expand Down Expand Up @@ -101,7 +102,7 @@ class BranchInterface(ui.ReactiveInterface, GitCommand):
[d] delete [h] fetch remote branches
[D] delete (force) [m] merge selected into active branch
[R] rename (local) [M] fetch and merge into active branch
[t] configure tracking
[t] configure tracking [u] unset upstream on selected branch
[f] diff against active [l] show branch log
[H] diff history against active [g] show branch log graph
Expand Down Expand Up @@ -724,3 +725,23 @@ def run(self, edit):
'branches': [self.selected_branch.canonical_name],
'follow': self.selected_branch.canonical_name
})


class gs_branches_unset_upstream(CommandForSingleBranch):

"""
Unset remote tracking for the selected branch.
"""

def run(self, edit):
if self.selected_branch.is_remote:
flash(self.view, "Cannot unset remote tracking for remote branches.")
return

if self.selected_branch.upstream == None:

Check failure on line 741 in core/interfaces/branch.py

View workflow job for this annotation

GitHub Actions / lint

comparison to None should be 'if cond is None:'
flash(self.view, "Cannot unset remote tracking for a branch without an upstream")
return

self.window.run_command('gs_unset_tracking_information', {
"branch": self.selected_branch.name
})

0 comments on commit 70aaeb1

Please sign in to comment.