mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 00:24:59 +00:00
feature<Archive>: supports archive by branches and tags
This commit is contained in:
parent
3f55d66e01
commit
5fbefad159
6 changed files with 61 additions and 9 deletions
|
@ -29,7 +29,7 @@
|
|||
Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.Commit}"/>
|
||||
<Path x:Name="iconBased" Width="14" Height="14" Data="{StaticResource Icon.Commit}"/>
|
||||
<TextBlock x:Name="txtBased" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
|
||||
|
@ -12,19 +14,43 @@ namespace SourceGit.Views.Popups {
|
|||
private string repo;
|
||||
private string revision;
|
||||
|
||||
public string SaveTo { get; set; } = "archive.zip";
|
||||
public string SaveTo { get; set; }
|
||||
|
||||
public Archive(string repo, Models.Branch branch) {
|
||||
this.repo = repo;
|
||||
this.revision = branch.Head;
|
||||
this.SaveTo = $"archive-{Path.GetFileNameWithoutExtension(branch.Name)}.zip";
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
iconBased.Data = FindResource("Icon.Branch") as Geometry;
|
||||
txtBased.Text = branch.IsLocal ? branch.Name : $"{branch.Remote}/{branch.Name}";
|
||||
}
|
||||
|
||||
public Archive(string repo, Models.Commit revision) {
|
||||
this.repo = repo;
|
||||
this.revision = revision.SHA;
|
||||
this.SaveTo = $"archive-{revision.ShortSHA}.zip";
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
iconBased.Data = FindResource("Icon.Commit") as Geometry;
|
||||
txtBased.Text = $"{revision.ShortSHA} {revision.Subject}";
|
||||
}
|
||||
|
||||
public Archive(string repo, Models.Tag tag) {
|
||||
this.repo = repo;
|
||||
this.revision = tag.SHA;
|
||||
this.SaveTo = $"archive-{tag.Name}.zip";
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
iconBased.Data = FindResource("Icon.Tag") as Geometry;
|
||||
txtBased.Text = tag.Name;
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("Archive");
|
||||
return App.Text("Archive.Title");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
|
|
|
@ -623,9 +623,17 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
menu.Items.Add(tracking);
|
||||
menu.Items.Add(new Separator());
|
||||
}
|
||||
|
||||
var archive = new MenuItem();
|
||||
archive.Header = App.Text("Archive");
|
||||
archive.Click += (o, e) => {
|
||||
new Popups.Archive(repo.Path, branch).Show();
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(archive);
|
||||
menu.Items.Add(new Separator());
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("BranchCM.CopyName");
|
||||
copy.Click += (o, e) => {
|
||||
|
@ -741,6 +749,13 @@ namespace SourceGit.Views.Widgets {
|
|||
e.Handled = true;
|
||||
};
|
||||
|
||||
var archive = new MenuItem();
|
||||
archive.Header = App.Text("Archive");
|
||||
archive.Click += (o, e) => {
|
||||
new Popups.Archive(repo.Path, branch).Show();
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("BranchCM.CopyName");
|
||||
copy.Click += (o, e) => {
|
||||
|
@ -752,6 +767,8 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(createBranch);
|
||||
menu.Items.Add(createTag);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(archive);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(copy);
|
||||
}
|
||||
|
@ -798,6 +815,13 @@ namespace SourceGit.Views.Widgets {
|
|||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var archive = new MenuItem();
|
||||
archive.Header = App.Text("Archive");
|
||||
archive.Click += (o, e) => {
|
||||
new Popups.Archive(repo.Path, tag).Show();
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("TagCM.Copy");
|
||||
copy.Click += (o, ev) => {
|
||||
|
@ -810,6 +834,8 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(pushTag);
|
||||
menu.Items.Add(deleteTag);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(archive);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(copy);
|
||||
menu.IsOpen = true;
|
||||
|
|
|
@ -350,7 +350,7 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(saveToPatch);
|
||||
|
||||
var archive = new MenuItem();
|
||||
archive.Header = App.Text("CommitCM.Archive");
|
||||
archive.Header = App.Text("Archive");
|
||||
archive.Click += (o, e) => {
|
||||
new Popups.Archive(repo.Path, commit).Show();
|
||||
e.Handled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue