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:
leo 2024-04-02 20:00:33 +08:00
parent 96e60da7ad
commit 96d4150d26
319 changed files with 37 additions and 53 deletions

View file

@ -0,0 +1,89 @@
using System.IO;
namespace SourceGit.ViewModels
{
public abstract class InProgressContext
{
public string Repository
{
get;
set;
}
public string Cmd
{
get;
set;
}
public InProgressContext(string repo, string cmd)
{
Repository = repo;
Cmd = cmd;
}
public void Abort()
{
new Commands.Command()
{
WorkingDirectory = Repository,
Context = Repository,
Args = $"{Cmd} --abort",
}.Exec();
}
public virtual bool Continue()
{
return new Commands.Command()
{
WorkingDirectory = Repository,
Context = Repository,
Args = $"-c core.editor=true {Cmd} --continue",
}.Exec();
}
}
public class CherryPickInProgress : InProgressContext
{
public CherryPickInProgress(string repo) : base(repo, "cherry-pick") { }
}
public class RebaseInProgress : InProgressContext
{
public RebaseInProgress(Repository repo) : base(repo.FullPath, "rebase")
{
_gitDir = repo.GitDir;
}
public override bool Continue()
{
var succ = base.Continue();
if (succ)
{
var rebaseMergeHead = Path.Combine(_gitDir, "REBASE_HEAD");
var rebaseMergeFolder = Path.Combine(_gitDir, "rebase-merge");
var rebaseApplyFolder = Path.Combine(_gitDir, "rebase-apply");
if (File.Exists(rebaseMergeHead))
File.Delete(rebaseMergeHead);
if (Directory.Exists(rebaseMergeFolder))
Directory.Delete(rebaseMergeFolder);
if (Directory.Exists(rebaseApplyFolder))
Directory.Delete(rebaseApplyFolder);
}
return succ;
}
private string _gitDir;
}
public class RevertInProgress : InProgressContext
{
public RevertInProgress(string repo) : base(repo, "revert") { }
}
public class MergeInProgress : InProgressContext
{
public MergeInProgress(string repo) : base(repo, "merge") { }
}
}