Skip to content

Commit 667070e

Browse files
committed
Change git sync to use fetch and checkout FETCH_HEAD instead of branches and pulling
1 parent dbae558 commit 667070e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

SS14.MapServer/Services/GitService.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public string Sync(string workingDirectory, string? gitRef = null, string? repoU
5959
if (!Directory.Exists(repoDirectory))
6060
Clone(repoUrl, repoDirectory, gitRef);
6161

62-
Pull(repoDirectory, gitRef);
62+
FetchAndCheckout(repoDirectory, repoUrl, gitRef);
6363

6464
return repoDirectory;
6565
}
@@ -97,9 +97,9 @@ private void Clone(string repoUrl, string directory, string gitRef)
9797
_log.Information("Done cloning");
9898
}
9999

100-
private void Pull(string repoDirectory, string gitRef)
100+
private void FetchAndCheckout(string repoDirectory, string repoUrl, string gitRef)
101101
{
102-
_log.Information( "Pulling branch/commit {Ref}...", gitRef);
102+
_log.Information( "Retrieving branch/commit {Ref}...", gitRef);
103103
_log.Debug("Opening repository in: {RepositoryPath}", repoDirectory);
104104

105105
//Set an identity
@@ -114,18 +114,15 @@ private void Pull(string repoDirectory, string gitRef)
114114
}
115115

116116
_log.Debug("Fetching ref");
117-
RunCommand(repoDirectory, "fetch -fu origin", gitRef);
117+
RunCommand(repoDirectory, "fetch -fu ", repoUrl, gitRef);
118118

119119
_log.Debug("Checking out {Ref}", StripRef(gitRef));
120-
RunCommand(repoDirectory, "checkout --force", StripRef(gitRef));
121-
122-
_log.Debug("Pulling latest changes");
123-
RunCommand(repoDirectory, "pull origin --ff-only --force", StripRef(gitRef));
124-
120+
RunCommand(repoDirectory, "checkout --quiet --force FETCH_HEAD");
121+
125122
_log.Debug("Updating submodules");
126123
RunCommand(repoDirectory, "submodule update --init --recursive");
127124

128-
_log.Information("Done pulling");
125+
_log.Information("Done retrieving");
129126
}
130127

131128
private string RunCommand(string directory, params string[] arguments)

0 commit comments

Comments
 (0)