Repository navigation
Expand file tree
/
Copy pathInProgressContexts.cs
More file actions
100 lines (87 loc) · 2.74 KB
/
Copy pathInProgressContexts.cs
File metadata and controls
100 lines (87 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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 bool Abort()
{
return new Commands.Command()
{
WorkingDirectory = Repository,
Context = Repository,
Args = $"{Cmd} --abort",
}.Exec();
}
public virtual bool Continue()
{
return new Commands.Command()
{
WorkingDirectory = Repository,
Context = Repository,
Editor = Commands.Command.EditorType.None,
Args = $"{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 = new Commands.Command()
{
WorkingDirectory = Repository,
Context = Repository,
Editor = Commands.Command.EditorType.RebaseEditor,
Args = $"rebase --continue",
}.Exec();
if (succ)
{
var jobsFile = Path.Combine(_gitDir, "sourcegit_rebase_jobs.json");
var rebaseMergeHead = Path.Combine(_gitDir, "REBASE_HEAD");
var rebaseMergeFolder = Path.Combine(_gitDir, "rebase-merge");
var rebaseApplyFolder = Path.Combine(_gitDir, "rebase-apply");
if (File.Exists(jobsFile))
File.Delete(jobsFile);
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") { }
}
}