Skip to content

Commit

Permalink
Set identity before git pulling
Browse files Browse the repository at this point in the history
Force git pull to ff only
  • Loading branch information
juliangiebel committed Sep 8, 2023
1 parent 79c58a4 commit 83ca8dd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions SS14.MapServer/Services/GitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ public string Sync(string workingDirectory, string? gitRef = null, string? repoU
if (!Path.IsPathRooted(repoDirectory))
repoDirectory = Path.Join(Directory.GetCurrentDirectory(), repoDirectory);


if (!Directory.Exists(repoDirectory))
Clone(repoUrl, repoDirectory, gitRef);

Pull(repoDirectory, gitRef);


return repoDirectory;
}

Expand Down Expand Up @@ -96,14 +94,19 @@ private void Pull(string repoDirectory, string gitRef)
_log.Debug("Opening repository in: {RepositoryPath}", repoDirectory);

using var repository = new Repository(repoDirectory);
//Set a dummy identity
_log.Debug("Setting identity");
repository.Config.Set("user.name", "ss14.mapserver");
repository.Config.Set("user.email", "[email protected]");

_log.Debug("Fetching ref");
_buildService.Run(repoDirectory, "git", new List<string> { "fetch origin", gitRef }).Wait();

_log.Debug("Checking out {Ref}", StripRef(gitRef));
Commands.Checkout(repository, StripRef(gitRef));

_log.Debug("Pulling latest changes");
_buildService.Run(repoDirectory, "git", new List<string> { "pull origin HEAD" }).Wait();
_buildService.Run(repoDirectory, "git", new List<string> { "pull origin HEAD --ff-only" }).Wait();

_log.Debug("Updating submodules");
foreach (var submodule in repository.Submodules)
Expand Down

0 comments on commit 83ca8dd

Please sign in to comment.