Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
269841c
Merge branch 'fixes/git-save-path-failure' into fixes/mac-path-variable
StanleyGoldman Mar 29, 2018
20fc378
Adding log messages to help debug this
StanleyGoldman Mar 29, 2018
3a0e572
Merge branch 'fixes/git-save-path-failure' into fixes/mac-path-variable
StanleyGoldman Mar 29, 2018
951780b
Fixing log message
StanleyGoldman Mar 29, 2018
e49517f
Moving log message
StanleyGoldman Mar 29, 2018
17df6c1
Merge branch 'fixes/git-save-path-failure' into fixes/mac-path-variable
StanleyGoldman Mar 29, 2018
85cd131
Merge branch 'fixes/git-save-path-failure' into enhancements/reset-to…
StanleyGoldman Mar 29, 2018
700500b
Adding functionality to change to the internal portable git if available
StanleyGoldman Mar 29, 2018
b6f205a
Specifying dontUseGit when finding git
StanleyGoldman Mar 29, 2018
81212c6
Merge branch 'enhancements/reset-to-internal-git' into fixes/mac-path…
StanleyGoldman Mar 29, 2018
a93b2cd
Merge branch 'fixes/findexectask-dontusegit' into fixes/mac-path-vari…
StanleyGoldman Mar 29, 2018
8f3800c
Making sure path for console matches ProcessEnvironment
StanleyGoldman Mar 29, 2018
2971a8a
Merge remote-tracking branch 'remotes/origin/fixes/open-shell-standar…
StanleyGoldman Mar 29, 2018
0237ef2
Tracking when git is custom vs internal
StanleyGoldman Mar 29, 2018
240dc81
Attempting to not change the PATH variable when validating git
StanleyGoldman Mar 29, 2018
f34016b
Fixing the load of the terminal and logging default system path
StanleyGoldman Mar 29, 2018
7a52d98
Making some code more like the original
StanleyGoldman Apr 2, 2018
0f55133
Commenting log message
StanleyGoldman Apr 2, 2018
3dd3616
Updating the Environment path with the output of path_helper
StanleyGoldman Apr 2, 2018
57e18a5
Removing vim stackdump
StanleyGoldman Apr 2, 2018
1a514a7
Removing some log messages
StanleyGoldman Apr 2, 2018
1e02102
Simplify getting the environment path initially
shana Apr 3, 2018
7b08073
If running bash fails, don't fail the whole chain, ignore the error a…
shana Apr 3, 2018
5562b63
Merge fixes/git-save-path-failure-cleanup into fixes/mac-path-variable
shana Apr 3, 2018
acfe268
Fix a bunch of stuff in the git installation process
shana Apr 4, 2018
0ab5759
Fix repository manager tests. Also fix a bug detecting tracking branches
shana Apr 4, 2018
cb9a037
Maybe these are happy in appveyor now?
shana Apr 4, 2018
0b3643e
Merge fixes/repository-tests-are-borked into fixes/mac-path-variable-…
shana Apr 4, 2018
f7bdc68
Maybe upping the timeout a bit will do?
shana Apr 4, 2018
3b76bf2
Reduce trace noise
shana Apr 5, 2018
537df2c
Improve cache trace messages
shana Apr 5, 2018
99f83c6
Fix CA warnings
shana Apr 5, 2018
11ffd11
Move to an async model in tests so we don't block the main thread
shana Apr 5, 2018
5dc0c79
Make repository manager tests more deterministic (still not working o…
shana Apr 5, 2018
7540d7c
Always return valid data from the downloader
shana Apr 5, 2018
d77f043
Continuations are set at the end of the task run
shana Apr 5, 2018
a681d18
Add some comments and set some windows-only env vars only on windows
shana Apr 5, 2018
39d7f45
We need to propagate finally handlers for ITask<T> types as well
shana Apr 5, 2018
a500ff2
Fix a problem with the git installation process
shana Apr 5, 2018
069a34a
Merge fixes/repository-tests-are-borked into fixes/mac-path-variable-…
shana Apr 5, 2018
ba24c19
Fix integration test git installer step
shana Apr 5, 2018
0f3bc38
Merge pull request #672 from github-for-unity/fixes/mac-path-variable…
shana Apr 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions src/GitHub.Api/Application/ApplicationManagerBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
Expand Down Expand Up @@ -54,14 +53,35 @@ public void Run(bool firstRun)
{
Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);

var initEnvironmentTask = new ActionTask<NPath>(CancellationToken,
(_, path) => InitializeEnvironment(path))
ITask<string> setExistingEnvironmentPath;
if (Environment.IsMac)
{
setExistingEnvironmentPath = new SimpleProcessTask(CancellationToken, "bash".ToNPath(), "-c \"/usr/libexec/path_helper\"")
.Configure(ProcessManager, dontSetupGit: true)
.Catch(e => true) // make sure this doesn't throw if the task fails
.Then((success, path) => success ? path.Split(new[] { "\"" }, StringSplitOptions.None)[1] : null);
}
else
{
setExistingEnvironmentPath = new FuncTask<string>(CancellationToken, () => null);
}

setExistingEnvironmentPath.OnEnd += (t, path, success, ex) => {
if (path != null)
{
Logger.Trace("Existing Environment Path Original:{0} Updated:{1}", Environment.Path, path);
Environment.Path = path;
}
};

var initEnvironmentTask = new ActionTask<GitInstaller.GitInstallationState>(CancellationToken,
(_, state) => InitializeEnvironment(state))
{ Affinity = TaskAffinity.UI };

isBusy = true;

var octorunInstaller = new OctorunInstaller(Environment, TaskManager);
var setupTask = octorunInstaller.SetupOctorunIfNeeded();
var setupTask = setExistingEnvironmentPath.Then(octorunInstaller.SetupOctorunIfNeeded());

var initializeGitTask = new FuncTask<NPath>(CancellationToken, () =>
{
Expand All @@ -87,7 +107,8 @@ public void Run(bool firstRun)
{
if (path.IsInitialized)
{
t.GetEndOfChain().Then(initEnvironmentTask, taskIsTopOfChain: true);
t.GetEndOfChain()
.Then(initEnvironmentTask, taskIsTopOfChain: true);
return;
}
Logger.Trace("Using portable git");
Expand All @@ -98,7 +119,8 @@ public void Run(bool firstRun)
task.Progress(progressReporter.UpdateProgress);
task.OnEnd += (thisTask, result, success, exception) =>
{
thisTask.GetEndOfChain().Then(initEnvironmentTask, taskIsTopOfChain: true);
thisTask.GetEndOfChain()
.Then(initEnvironmentTask, taskIsTopOfChain: true);
};

// append installer task to top chain
Expand Down Expand Up @@ -205,17 +227,23 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
/// </summary>
/// <param name="gitExecutablePath"></param>
/// <param name="octorunScriptPath"></param>
private void InitializeEnvironment(NPath gitExecutablePath)
private void InitializeEnvironment(GitInstaller.GitInstallationState installationState)
{
isBusy = false;
SetupMetrics();

if (!gitExecutablePath.IsInitialized)
if (!installationState.GitIsValid)
{
return;
}

Environment.GitExecutablePath = gitExecutablePath;
var gitInstallDetails = new GitInstaller.GitInstallDetails(Environment.UserCachePath, Environment.IsWindows);
var isCustomGitExec = installationState.GitExecutablePath != gitInstallDetails.GitExecutablePath;

Environment.GitExecutablePath = installationState.GitExecutablePath;
Environment.GitLfsExecutablePath = installationState.GitLfsExecutablePath;

Environment.IsCustomGitExecutable = isCustomGitExec;
Environment.User.Initialize(GitClient);

var afterGitSetup = new ActionTask(CancellationToken, RestartRepository)
Expand All @@ -226,7 +254,7 @@ private void InitializeEnvironment(NPath gitExecutablePath)
{
var credHelperTask = GitClient.GetConfig("credential.helper", GitConfigSource.Global);
credHelperTask.OnEnd += (thisTask, credentialHelper, success, exception) =>
{
{
if (!success || string.IsNullOrEmpty(credentialHelper))
{
Logger.Warning("No Windows CredentialHelper found: Setting to wincred");
Expand Down
2 changes: 0 additions & 2 deletions src/GitHub.Api/Cache/CacheContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ public void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEven

private void OnCacheUpdated(CacheType cacheType, DateTimeOffset datetime)
{
Logger.Trace("OnCacheUpdated cacheType:{0} datetime:{1}", cacheType, datetime);
CacheUpdated.SafeInvoke(cacheType, datetime);
}

private void OnCacheInvalidated(CacheType cacheType)
{
Logger.Trace("OnCacheInvalidated cacheType:{0}", cacheType);
CacheInvalidated.SafeInvoke(cacheType);
}

Expand Down
10 changes: 6 additions & 4 deletions src/GitHub.Api/Git/GitClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace GitHub.Unity
{
public interface IGitClient
{
ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path);
ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path, bool isCustomGit);

ITask Init(IOutputProcessor<string> processor = null);

Expand Down Expand Up @@ -110,7 +110,7 @@ public GitClient(IEnvironment environment, IProcessManager processManager, Cance
this.cancellationToken = cancellationToken;
}

public ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path)
public ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path, bool isCustomGit)
{
Version gitVersion = null;
Version gitLfsVersion = null;
Expand All @@ -123,9 +123,11 @@ public ITask<ValidateGitInstallResult> ValidateGitInstall(NPath path)

if (path.FileExists())
{
var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken).Configure(processManager, path);
var gitLfsVersionTask = new GitLfsVersionTask(cancellationToken)
.Configure(processManager, path, dontSetupGit: isCustomGit);
gitLfsVersionTask.OnEnd += (t, v, _, __) => gitLfsVersion = v;
var gitVersionTask = new GitVersionTask(cancellationToken).Configure(processManager, path);
var gitVersionTask = new GitVersionTask(cancellationToken)
.Configure(processManager, path, dontSetupGit: isCustomGit);
gitVersionTask.OnEnd += (t, v, _, __) => gitVersion = v;

gitVersionTask
Expand Down
10 changes: 7 additions & 3 deletions src/GitHub.Api/Git/GitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,20 @@ public struct ConfigBranch

public string name;
public ConfigRemote remote;
public string trackingBranch;

public ConfigBranch(string name)
{
this.name = name;
this.trackingBranch = null;
remote = ConfigRemote.Default;
}

public ConfigBranch(string name, ConfigRemote? remote)
public ConfigBranch(string name, ConfigRemote? remote, string trackingBranch)
{
this.name = name;
this.remote = remote ?? ConfigRemote.Default;
this.trackingBranch = trackingBranch != null && trackingBranch.StartsWith("refs/heads") ? trackingBranch.Substring("refs/heads".Length + 1) : null;
}

public override int GetHashCode()
Expand Down Expand Up @@ -137,6 +140,7 @@ public bool Equals(ConfigBranch other)
public bool IsTracking => Remote.HasValue;

public string Name => name;
public string TrackingBranch => trackingBranch;

public ConfigRemote? Remote => Equals(remote, ConfigRemote.Default) ? (ConfigRemote?) null : remote;

Expand Down Expand Up @@ -189,7 +193,7 @@ public IEnumerable<ConfigBranch> GetBranches()
return groups
.Where(x => x.Key == "branch")
.SelectMany(x => x.Value)
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote"))));
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")));
}

public IEnumerable<ConfigRemote> GetRemotes()
Expand Down Expand Up @@ -217,7 +221,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
.Where(x => x.Key == "branch")
.SelectMany(x => x.Value)
.Where(x => x.Key == branch)
.Select(x => new ConfigBranch(x.Key,GetRemote(x.Value.TryGetString("remote"))) as ConfigBranch?)
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")) as ConfigBranch?)
.FirstOrDefault();
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.Api/Git/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GitHub.Unity
/// </summary>
public interface IRepository : IEquatable<IRepository>, IDisposable
{
void Initialize(IRepositoryManager repositoryManager, ITaskManager taskManager);
void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager);
void Start();

ITask CommitAllFiles(string message, string body);
Expand Down
11 changes: 5 additions & 6 deletions src/GitHub.Api/Git/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ public Repository(NPath localPath, ICacheContainer container)
};
}

public void Initialize(IRepositoryManager repositoryManager, ITaskManager taskManager)
public void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager)
{
//Logger.Trace("Initialize");
Guard.ArgumentNotNull(repositoryManager, nameof(repositoryManager));
Guard.ArgumentNotNull(taskManager, nameof(taskManager));
Guard.ArgumentNotNull(theRepositoryManager, nameof(theRepositoryManager));
Guard.ArgumentNotNull(theTaskManager, nameof(theTaskManager));

this.taskManager = taskManager;
this.repositoryManager = repositoryManager;
this.taskManager = theTaskManager;
this.repositoryManager = theRepositoryManager;
this.repositoryManager.CurrentBranchUpdated += RepositoryManagerOnCurrentBranchUpdated;
this.repositoryManager.GitStatusUpdated += RepositoryManagerOnGitStatusUpdated;
this.repositoryManager.GitAheadBehindStatusUpdated += RepositoryManagerOnGitAheadBehindStatusUpdated;
Expand Down Expand Up @@ -176,7 +176,6 @@ private void CacheHasBeenInvalidated(CacheType cacheType)
return;
}

Logger.Trace($"CacheInvalidated {cacheType.ToString()}");
switch (cacheType)
{
case CacheType.Branches:
Expand Down
9 changes: 7 additions & 2 deletions src/GitHub.Api/Git/RepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void UpdateGitAheadBehindStatus()
if (configBranch.HasValue && configBranch.Value.Remote.HasValue)
{
var name = configBranch.Value.Name;
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + name : "[None]";
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + configBranch.Value.TrackingBranch : "[None]";

var task = GitClient.AheadBehindStatus(name, trackingName)
.Then((success, status) =>
Expand Down Expand Up @@ -491,6 +491,10 @@ private void WatcherOnLocalBranchesChanged()
{
Logger.Trace("WatcherOnLocalBranchesChanged");
DataNeedsRefreshing?.Invoke(CacheType.Branches);
// the watcher should tell us what branch has changed so we can fire this only
// when the active branch has changed
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
}

private void WatcherOnRepositoryCommitted()
Expand Down Expand Up @@ -520,6 +524,7 @@ private void WatcherOnHeadChanged()
Logger.Trace("WatcherOnHeadChanged");
DataNeedsRefreshing?.Invoke(CacheType.RepositoryInfo);
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
}

private void WatcherOnIndexChanged()
Expand Down Expand Up @@ -577,7 +582,7 @@ private void UpdateRemoteBranches()
.Select(x => x.RelativeTo(basedir))
.Select(x => x.ToString(SlashMode.Forward)))
{
branchList.Add(branch, new ConfigBranch(branch, remotes[remote]));
branchList.Add(branch, new ConfigBranch(branch, remotes[remote], null));
}

remoteBranches.Add(remote, branchList);
Expand Down
Loading