-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on ssh support for repositories
- Loading branch information
1 parent
71c0d22
commit e2e6369
Showing
2 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,9 @@ public sealed class GitConfiguration | |
public const string Name = "Git"; | ||
|
||
public string RepositoryUrl { get; set; } = string.Empty; | ||
|
||
public string Branch { get; set; } = "master"; | ||
|
||
/// <summary> | ||
/// If true the map server will retrieve the list of changed maps from the github diff api. | ||
/// If this is false all maps will get updated on every push. | ||
|
@@ -24,13 +24,13 @@ public sealed class GitConfiguration | |
{ | ||
"Resources/Maps/*.yml" | ||
}; | ||
|
||
/// <summary> | ||
/// Glob patterns for excluding specific map files | ||
/// </summary> | ||
public List<string> MapFileExcludePatterns { get; set; } = new(); | ||
|
||
|
||
/// <summary> | ||
/// Prevent updating maps when there where any c# files changed. | ||
/// </summary> | ||
|
@@ -48,9 +48,23 @@ public sealed class GitConfiguration | |
{ | ||
"**/*.cs" | ||
}; | ||
|
||
/// <summary> | ||
/// Setting this to true enables listening to the PullRequest event for putting the rendered map as a comment into the PR | ||
/// </summary> | ||
public bool RunOnPullRequests { get; set; } = true; | ||
} | ||
|
||
/// <summary> | ||
/// The identity git will use to pull changes with. This doesn't have an effect on anything but is required | ||
/// for pulling changes in some situations | ||
/// </summary> | ||
public GitIdentity Identity { get; set; } = new GitIdentity("ss14.mapserver", "[email protected]"); | ||
|
||
/// <summary> | ||
/// The ssh command used by git if set. Used for providing an ssh key to use. | ||
/// <example>"ssh -i [path to ssh key]"</example> | ||
/// </summary> | ||
public string? SshCommand { get; set; } | ||
|
||
public record GitIdentity(string Name, string Email); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,9 @@ public static string StripRef(string gitRef) | |
private void Clone(string repoUrl, string directory, string gitRef) | ||
{ | ||
_log.Information("Cloning branch/commit {Ref}...", gitRef); | ||
var repoDirectory = Repository.Clone(repoUrl, directory, new CloneOptions | ||
|
||
|
||
/*var repoDirectory = Repository.Clone(repoUrl, directory, new CloneOptions | ||
{ | ||
RecurseSubmodules = true, | ||
OnProgress = LogProgress | ||
|
@@ -85,7 +87,7 @@ private void Clone(string repoUrl, string directory, string gitRef) | |
}, | ||
null); | ||
Commands.Checkout(repository, StripRef(gitRef)); | ||
Commands.Checkout(repository, StripRef(gitRef));*/ | ||
_log.Information("Done cloning"); | ||
} | ||
|
||
|
@@ -95,10 +97,16 @@ private void Pull(string repoDirectory, string gitRef) | |
_log.Debug("Opening repository in: {RepositoryPath}", repoDirectory); | ||
|
||
using var repository = new Repository(repoDirectory); | ||
//Set a dummy identity | ||
//Set an identity | ||
_log.Debug("Setting identity"); | ||
repository.Config.Set("user.name", "ss14.mapserver"); | ||
repository.Config.Set("user.email", "[email protected]"); | ||
repository.Config.Set("user.name", _configuration.Identity.Name); | ||
repository.Config.Set("user.email", _configuration.Identity.Email); | ||
|
||
if (_configuration.SshCommand != null) | ||
{ | ||
_log.Debug("Setting ssh command"); | ||
repository.Config.Set("core.sshcommand", _configuration.SshCommand); | ||
} | ||
|
||
_log.Debug("Fetching ref"); | ||
_buildService.Run(repoDirectory, "git", new List<string> { "fetch -fu origin", gitRef }).Wait(); | ||
|