mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
project: reorganize the structure of the project.
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
parent
96e60da7ad
commit
96d4150d26
319 changed files with 37 additions and 53 deletions
73
src/ViewModels/Archive.cs
Normal file
73
src/ViewModels/Archive.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Archive : Popup
|
||||
{
|
||||
|
||||
[Required(ErrorMessage = "Output file name is required")]
|
||||
public string SaveFile
|
||||
{
|
||||
get => _saveFile;
|
||||
set => SetProperty(ref _saveFile, value, true);
|
||||
}
|
||||
|
||||
public object BasedOn
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Archive(Repository repo, Models.Branch branch)
|
||||
{
|
||||
_repo = repo;
|
||||
_revision = branch.Head;
|
||||
_saveFile = $"archive-{Path.GetFileNameWithoutExtension(branch.Name)}.zip";
|
||||
BasedOn = branch;
|
||||
View = new Views.Archive() { DataContext = this };
|
||||
}
|
||||
|
||||
public Archive(Repository repo, Models.Commit commit)
|
||||
{
|
||||
_repo = repo;
|
||||
_revision = commit.SHA;
|
||||
_saveFile = $"archive-{commit.SHA.Substring(0, 10)}.zip";
|
||||
BasedOn = commit;
|
||||
View = new Views.Archive() { DataContext = this };
|
||||
}
|
||||
|
||||
public Archive(Repository repo, Models.Tag tag)
|
||||
{
|
||||
_repo = repo;
|
||||
_revision = tag.SHA;
|
||||
_saveFile = $"archive-{tag.Name}.zip";
|
||||
BasedOn = tag;
|
||||
View = new Views.Archive() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Archiving ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Archive(_repo.FullPath, _revision, _saveFile, SetProgressDescription).Exec();
|
||||
CallUIThread(() =>
|
||||
{
|
||||
_repo.SetWatcherEnabled(true);
|
||||
if (succ)
|
||||
App.SendNotification(_repo.FullPath, $"Save archive to : {_saveFile}");
|
||||
});
|
||||
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private string _saveFile = string.Empty;
|
||||
private readonly string _revision = string.Empty;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue