private void GetTreeish(GitRepository repo, Dep dep, string[] force, string treeish, GetInfo getInfo) { treeish = treeish ?? "master"; Log.LogInformation($"{"[" + dep.Name + "]",-30}Getting treeish '{treeish}'"); var hasRemoteBranch = repo.HasRemoteBranch(treeish); getInfo.ForcedBranch = HaveToForce(dep, force, repo); if (getInfo.Forced) { treeish = getInfo.ForcedBranch; Log.LogInformation($"{"[" + dep.Name + "]",-30}treeish '{treeish}' was forced"); } ConsoleWriter.WriteProgress(dep.Name + "/" + dep.Configuration + "\t" + treeish); var oldSha = repo.SafeGetCurrentLocalCommitHash(); var remoteSha = repo.HasRemoteBranch(treeish) ? repo.RemoteCommitHashAtBranch(treeish) : treeish; var localChangesAction = DefineLocalChangesPolicy(repo, oldSha, remoteSha); if (localChangesAction == LocalChangesAction.ForceLocal) { getInfo.ForcedLocal = true; return; } if (localChangesAction == LocalChangesAction.Reset) { Reset(repo, dep); getInfo.Reset = true; } ConsoleWriter.WriteProgress(dep.Name + " looking for remote commit hash"); if (hasRemoteBranch && repo.RemoteCommitHashAtBranch(treeish).Equals(oldSha) && repo.CurrentLocalTreeish().Value.Equals(treeish)) { return; } if (repo.HasLocalBranch(treeish)) { ConsoleWriter.WriteProgress(dep.Name + " has local branch " + treeish); Log.LogInformation($"{"[" + dep.Name + "]",-30}has local branch '{treeish}'"); ConsoleWriter.WriteProgress(dep.Name + " checkout " + treeish); repo.Checkout(treeish); if (hasRemoteBranch) { if (userLocalChangesPolicy == LocalChangesPolicy.Reset && !repo.FastForwardPullAllowed(treeish)) { repo.ResetHard(treeish); } else { ConsoleWriter.WriteProgress(dep.Name + " pull " + treeish); repo.Pull(treeish); } } } else { Log.LogInformation($"{"[" + dep.Name + "]",-30}doesn't have local branch '{treeish}'"); ConsoleWriter.WriteProgress(dep.Name + " fetch " + treeish); repo.Fetch(repo.HasRemoteBranch(treeish) ? treeish : "", gitDepth); ConsoleWriter.WriteProgress(dep.Name + " checkout " + treeish); repo.Checkout(treeish); } var newSha = repo.CurrentLocalCommitHash(); getInfo.Reset = false; if (userLocalChangesPolicy == LocalChangesPolicy.Reset && hasRemoteBranch && !repo.RemoteCommitHashAtBranch(treeish).Equals(newSha)) { repo.ResetHard(treeish); getInfo.Reset = true; } getInfo.Changed = !oldSha.Equals(newSha); getInfo.Pulled = localChangesAction == LocalChangesAction.Pull; }