From a112d212dc75977af74118b86240a88f92afa8f3 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 13 Jan 2025 20:41:03 +0800 Subject: [PATCH] enhance: disable pull/stash/apply/git-flow/git-lfs buttons in `bare` repository --- src/Views/CreateBranch.axaml | 2 +- src/Views/RepositoryToolbar.axaml | 10 +++++----- src/Views/RepositoryToolbar.axaml.cs | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Views/CreateBranch.axaml b/src/Views/CreateBranch.axaml index d8b89eb4..49bfda8d 100644 --- a/src/Views/CreateBranch.axaml +++ b/src/Views/CreateBranch.axaml @@ -70,7 +70,7 @@ Text="{DynamicResource Text.CreateBranch.LocalChanges}" IsVisible="{Binding !IsBareRepository}"/> - + - - - @@ -88,11 +88,11 @@ - - diff --git a/src/Views/RepositoryToolbar.axaml.cs b/src/Views/RepositoryToolbar.axaml.cs index aa78c4d3..66b49fc2 100644 --- a/src/Views/RepositoryToolbar.axaml.cs +++ b/src/Views/RepositoryToolbar.axaml.cs @@ -59,6 +59,12 @@ namespace SourceGit.Views var launcher = this.FindAncestorOfType(); if (launcher is not null && DataContext is ViewModels.Repository repo) { + if (repo.IsBare) + { + App.RaiseException(repo.FullPath, "Can't run `git pull` in bare repository!"); + return; + } + var startDirectly = launcher.HasKeyModifier(KeyModifiers.Control); launcher.ClearKeyModifier(); repo.Pull(startDirectly);