mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08: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
|
@ -39,7 +39,8 @@
|
||||||
<sys:String x:Key="Text.Apply.ErrorAll">Error All</sys:String>
|
<sys:String x:Key="Text.Apply.ErrorAll">Error All</sys:String>
|
||||||
<sys:String x:Key="Text.Apply.ErrorAll.Desc">Similar to 'error', but shows more</sys:String>
|
<sys:String x:Key="Text.Apply.ErrorAll.Desc">Similar to 'error', but shows more</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Archive">Archive</sys:String>
|
<sys:String x:Key="Text.Archive">Archive ...</sys:String>
|
||||||
|
<sys:String x:Key="Text.Archive.Title">Archive</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.Revision">Revision :</sys:String>
|
<sys:String x:Key="Text.Archive.Revision">Revision :</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.File">Save Archive To :</sys:String>
|
<sys:String x:Key="Text.Archive.File">Save Archive To :</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.File.Placeholder">Select archive file path</sys:String>
|
<sys:String x:Key="Text.Archive.File.Placeholder">Select archive file path</sys:String>
|
||||||
|
@ -190,7 +191,6 @@
|
||||||
<sys:String x:Key="Text.CommitCM.CherryPick">Cherry-Pick This Commit</sys:String>
|
<sys:String x:Key="Text.CommitCM.CherryPick">Cherry-Pick This Commit</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.Revert">Revert Commit</sys:String>
|
<sys:String x:Key="Text.CommitCM.Revert">Revert Commit</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.SaveAsPatch">Save as Patch ...</sys:String>
|
<sys:String x:Key="Text.CommitCM.SaveAsPatch">Save as Patch ...</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.Archive">Archive ...</sys:String>
|
|
||||||
<sys:String x:Key="Text.CommitCM.CopySHA">Copy Commit SHA</sys:String>
|
<sys:String x:Key="Text.CommitCM.CopySHA">Copy Commit SHA</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.CopyInfo">Copy Commit Info</sys:String>
|
<sys:String x:Key="Text.CommitCM.CopyInfo">Copy Commit Info</sys:String>
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@
|
||||||
<sys:String x:Key="Text.Apply.ErrorAll">更多错误</sys:String>
|
<sys:String x:Key="Text.Apply.ErrorAll">更多错误</sys:String>
|
||||||
<sys:String x:Key="Text.Apply.ErrorAll.Desc">与【错误】级别相似,但输出内容更多</sys:String>
|
<sys:String x:Key="Text.Apply.ErrorAll.Desc">与【错误】级别相似,但输出内容更多</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Archive">存档</sys:String>
|
<sys:String x:Key="Text.Archive">存档 ...</sys:String>
|
||||||
|
<sys:String x:Key="Text.Archive.Title">存档</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.Revision">指定的提交:</sys:String>
|
<sys:String x:Key="Text.Archive.Revision">指定的提交:</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.File">存档文件路径:</sys:String>
|
<sys:String x:Key="Text.Archive.File">存档文件路径:</sys:String>
|
||||||
<sys:String x:Key="Text.Archive.File.Placeholder">选择存档文件的存放路径</sys:String>
|
<sys:String x:Key="Text.Archive.File.Placeholder">选择存档文件的存放路径</sys:String>
|
||||||
|
@ -190,7 +191,6 @@
|
||||||
<sys:String x:Key="Text.CommitCM.CherryPick">挑选此提交</sys:String>
|
<sys:String x:Key="Text.CommitCM.CherryPick">挑选此提交</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.Revert">回滚此提交</sys:String>
|
<sys:String x:Key="Text.CommitCM.Revert">回滚此提交</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.SaveAsPatch">另存为补丁 ...</sys:String>
|
<sys:String x:Key="Text.CommitCM.SaveAsPatch">另存为补丁 ...</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.Archive">存档 ...</sys:String>
|
|
||||||
<sys:String x:Key="Text.CommitCM.CopySHA">复制提交指纹</sys:String>
|
<sys:String x:Key="Text.CommitCM.CopySHA">复制提交指纹</sys:String>
|
||||||
<sys:String x:Key="Text.CommitCM.CopyInfo">复制提交信息</sys:String>
|
<sys:String x:Key="Text.CommitCM.CopyInfo">复制提交信息</sys:String>
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
Grid.Row="0" Grid.Column="1"
|
Grid.Row="0" Grid.Column="1"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
VerticalAlignment="Center">
|
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"/>
|
<TextBlock x:Name="txtBased" Margin="8,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace SourceGit.Views.Popups {
|
namespace SourceGit.Views.Popups {
|
||||||
|
|
||||||
|
@ -12,19 +14,43 @@ namespace SourceGit.Views.Popups {
|
||||||
private string repo;
|
private string repo;
|
||||||
private string revision;
|
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) {
|
public Archive(string repo, Models.Commit revision) {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.revision = revision.SHA;
|
this.revision = revision.SHA;
|
||||||
|
this.SaveTo = $"archive-{revision.ShortSHA}.zip";
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
iconBased.Data = FindResource("Icon.Commit") as Geometry;
|
||||||
txtBased.Text = $"{revision.ShortSHA} {revision.Subject}";
|
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() {
|
public override string GetTitle() {
|
||||||
return App.Text("Archive");
|
return App.Text("Archive.Title");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Start() {
|
public override Task<bool> Start() {
|
||||||
|
|
|
@ -623,9 +623,17 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.Items.Add(tracking);
|
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();
|
var copy = new MenuItem();
|
||||||
copy.Header = App.Text("BranchCM.CopyName");
|
copy.Header = App.Text("BranchCM.CopyName");
|
||||||
copy.Click += (o, e) => {
|
copy.Click += (o, e) => {
|
||||||
|
@ -741,6 +749,13 @@ namespace SourceGit.Views.Widgets {
|
||||||
e.Handled = true;
|
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();
|
var copy = new MenuItem();
|
||||||
copy.Header = App.Text("BranchCM.CopyName");
|
copy.Header = App.Text("BranchCM.CopyName");
|
||||||
copy.Click += (o, e) => {
|
copy.Click += (o, e) => {
|
||||||
|
@ -753,6 +768,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
menu.Items.Add(createBranch);
|
menu.Items.Add(createBranch);
|
||||||
menu.Items.Add(createTag);
|
menu.Items.Add(createTag);
|
||||||
menu.Items.Add(new Separator());
|
menu.Items.Add(new Separator());
|
||||||
|
menu.Items.Add(archive);
|
||||||
|
menu.Items.Add(new Separator());
|
||||||
menu.Items.Add(copy);
|
menu.Items.Add(copy);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -798,6 +815,13 @@ namespace SourceGit.Views.Widgets {
|
||||||
ev.Handled = true;
|
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();
|
var copy = new MenuItem();
|
||||||
copy.Header = App.Text("TagCM.Copy");
|
copy.Header = App.Text("TagCM.Copy");
|
||||||
copy.Click += (o, ev) => {
|
copy.Click += (o, ev) => {
|
||||||
|
@ -811,6 +835,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
menu.Items.Add(pushTag);
|
menu.Items.Add(pushTag);
|
||||||
menu.Items.Add(deleteTag);
|
menu.Items.Add(deleteTag);
|
||||||
menu.Items.Add(new Separator());
|
menu.Items.Add(new Separator());
|
||||||
|
menu.Items.Add(archive);
|
||||||
|
menu.Items.Add(new Separator());
|
||||||
menu.Items.Add(copy);
|
menu.Items.Add(copy);
|
||||||
menu.IsOpen = true;
|
menu.IsOpen = true;
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
|
@ -350,7 +350,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
menu.Items.Add(saveToPatch);
|
menu.Items.Add(saveToPatch);
|
||||||
|
|
||||||
var archive = new MenuItem();
|
var archive = new MenuItem();
|
||||||
archive.Header = App.Text("CommitCM.Archive");
|
archive.Header = App.Text("Archive");
|
||||||
archive.Click += (o, e) => {
|
archive.Click += (o, e) => {
|
||||||
new Popups.Archive(repo.Path, commit).Show();
|
new Popups.Archive(repo.Path, commit).Show();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
Loading…
Reference in a new issue