private static void CloneInNotEmptyFolder(Module module, GitRepository repo) { repo.Init(); repo.AddOrigin(module.Url); repo.Fetch(""); repo.ResetHard("master"); repo.DeleteUntrackedFiles(); }
private void CloneInNotEmptyFolder(Module module, GitRepository repo) { repo.Init(); repo.AddOrigin(module.Url); if (module.Pushurl != null) { repo.SetPushUrl(module.Pushurl); } repo.Fetch("", gitDepth); repo.ResetHard("master"); repo.DeleteUntrackedFiles(); }
private void GetTreeish(GitRepository repo, Dep dep, string force, string treeish, GetInfo getInfo) { treeish = treeish ?? "master"; Log.Info($"{"[" + dep.Name + "]",-30}Getting treeish '{treeish}'"); var hasRemoteBranch = repo.HasRemoteBranch(treeish); getInfo.Forced = HaveToForce(dep, force, repo); if (getInfo.Forced) { treeish = force; Log.Info($"{"[" + 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.Info($"{"[" + 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.Info($"{"[" + dep.Name + "]",-30}doesn't have local branch '{treeish}'"); ConsoleWriter.WriteProgress(dep.Name + " fetch " + treeish); if (repo.HasRemoteBranch(treeish)) { repo.Fetch(treeish); } else { repo.Fetch(""); } 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; }