mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-25 22:17:51 +01:00
MergePullRequest now accepts an atSHA parameter
This commit is contained in:
@@ -861,14 +861,14 @@ namespace TGServerService
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string MergePullRequest(int PRNumber)
|
||||
public string MergePullRequest(int PRNumber, string atSHA)
|
||||
{
|
||||
lock (RepoLock)
|
||||
{
|
||||
var result = LoadRepo();
|
||||
if (result != null)
|
||||
return result;
|
||||
SendMessage(String.Format("REPO: Merging PR #{0}...", PRNumber), MessageType.DeveloperInfo);
|
||||
SendMessage(String.Format("REPO: Merging PR #{0}{1}...", PRNumber, atSHA != null ? String.Format(" at commit {0}", atSHA): ""), MessageType.DeveloperInfo);
|
||||
result = ResetNoLock(null);
|
||||
if (result != null)
|
||||
return result;
|
||||
@@ -905,8 +905,28 @@ namespace TGServerService
|
||||
return String.Format("PR #{0} could not be fetched. Does it exist?", PRNumber);
|
||||
}
|
||||
|
||||
if (atSHA != null)
|
||||
{
|
||||
//find the commit
|
||||
Commit commit = null;
|
||||
string error = null;
|
||||
try
|
||||
{
|
||||
commit = Repo.Lookup<Commit>(atSHA);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
error = e.ToString();
|
||||
}
|
||||
if (commit == null)
|
||||
{
|
||||
SendMessage("REPO: Commit could not be found, aborting!", MessageType.DeveloperInfo);
|
||||
return error ?? String.Format("Commit {0} could not be found in the repository!", atSHA);
|
||||
}
|
||||
}
|
||||
|
||||
//so we'll know if this fails
|
||||
var Result = MergeBranch(LocalBranchName, String.Format("Testmerge commit for pull request #{0}", PRNumber));
|
||||
var Result = MergeBranch(atSHA ?? LocalBranchName, String.Format("Testmerge commit for pull request #{0}", PRNumber));
|
||||
|
||||
if (Result == null)
|
||||
try
|
||||
|
||||
@@ -92,9 +92,10 @@ namespace TGServiceInterface.Components
|
||||
/// Merges the target pull request into the current branch if the remote is a github repository
|
||||
/// </summary>
|
||||
/// <param name="PRnumber">The github pull request number in the remote repository</param>
|
||||
/// <param name="atSHA">The SHA of the pull request to merge</param>
|
||||
/// <returns><see langword="null"/> on success, error message on failure</returns>
|
||||
[OperationContract]
|
||||
string MergePullRequest(int PRnumber);
|
||||
string MergePullRequest(int PRnumber, string atSHA = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get the currently merged pull requests. Note that switching branches will delete this list and switching back won't restore it
|
||||
|
||||
Reference in New Issue
Block a user