Skip to content

Commit b7d643e

Browse files
committed
feature: remember the last selection of tag type in Create Tag popup (sourcegit-scm#2128)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 4df6574 commit b7d643e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/Models/RepositoryUIStates.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ public bool PushAllTags
117117
set;
118118
} = false;
119119

120+
public bool CreateAnnotatedTag
121+
{
122+
get;
123+
set;
124+
} = true;
125+
120126
public bool PushToRemoteWhenCreateTag
121127
{
122128
get;
@@ -218,7 +224,7 @@ public static RepositoryUIStates Load(string gitDir)
218224
var fileInfo = new FileInfo(Path.Combine(gitDir, "sourcegit.uistates"));
219225
var fullpath = fileInfo.FullName;
220226

221-
RepositoryUIStates states = null;
227+
RepositoryUIStates states;
222228
if (!File.Exists(fullpath))
223229
{
224230
states = new RepositoryUIStates();

src/ViewModels/CreateTag.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ public string Message
2929

3030
public bool Annotated
3131
{
32-
get => _annotated;
33-
set => SetProperty(ref _annotated, value);
32+
get => _repo.UIStates.CreateAnnotatedTag;
33+
set
34+
{
35+
if (_repo.UIStates.CreateAnnotatedTag != value)
36+
{
37+
_repo.UIStates.CreateAnnotatedTag = value;
38+
OnPropertyChanged();
39+
}
40+
}
3441
}
3542

3643
public bool SignTag
@@ -83,9 +90,11 @@ public override async Task<bool> Sure()
8390
var log = _repo.CreateLog("Create Tag");
8491
Use(log);
8592

86-
var cmd = new Commands.Tag(_repo.FullPath, _tagName).Use(log);
87-
var succ = false;
88-
if (_annotated)
93+
var cmd = new Commands.Tag(_repo.FullPath, _tagName)
94+
.Use(log);
95+
96+
bool succ;
97+
if (_repo.UIStates.CreateAnnotatedTag)
8998
succ = await cmd.AddAsync(_basedOn, Message, SignTag);
9099
else
91100
succ = await cmd.AddAsync(_basedOn);
@@ -104,7 +113,6 @@ public override async Task<bool> Sure()
104113

105114
private readonly Repository _repo = null;
106115
private string _tagName = string.Empty;
107-
private bool _annotated = true;
108116
private readonly string _basedOn;
109117
}
110118
}

src/Views/CreateTag.axaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@
6262
Text="{DynamicResource Text.CreateTag.Type}"/>
6363
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
6464
<RadioButton Content="{DynamicResource Text.CreateTag.Type.Annotated}"
65-
GroupName="TagKind"
6665
IsChecked="{Binding Annotated, Mode=TwoWay}"/>
6766
<RadioButton Content="{DynamicResource Text.CreateTag.Type.Lightweight}"
68-
GroupName="TagKind"
67+
IsChecked="{Binding !Annotated, Mode=TwoWay}"
6968
Margin="8,0,0,0"/>
7069
</StackPanel>
7170

0 commit comments

Comments
 (0)