public void GitPushTest_AuthenticationFailed() { var gitOutput = new ExecuteInfo(false, new List<string>(), new List<string> { @"bash: /dev/tty: No such device or address", @"error: failed to execute prompt script (exit code 1)", @"fatal: could not read Username for 'https://github.com': Invalid argument" }); var pushResult = GitModuleInfo.ConvertToGitPushResult(gitOutput); Assert.AreEqual(GitPushResult.NoCredentials, pushResult); }
public void GitPushTest_PullNeeded() { var gitOutput = new ExecuteInfo(false, new List<string>(), new List<string> { @"To D:/Project/02", @"! [rejected] AA-004 -> AA-004 (non-fast-forward)", @"error: failed to push some refs to 'D:/Work2/GitWithSubmodules/02'", @"hint: Updates were rejected because the tip of your current branch is behind", @"hint: its remote counterpart. Integrate the remote changes (e.g.", @"hint: 'git pull ...') before pushing again.", @"hint: See the 'Note about fast-forwards' in 'git push --help' for details." }); var pushResult = GitModuleInfo.ConvertToGitPushResult(gitOutput); Assert.AreEqual(GitPushResult.PullNeeded, pushResult); }
public static GitPushResult ConvertToGitPushResult(ExecuteInfo gitResult) { if (gitResult.Success) return GitPushResult.Success; if (gitResult.Error.Contains("git pull")) return GitPushResult.PullNeeded; if (gitResult.Error.Contains("Authentication failed")) return GitPushResult.AuthenticationFailed; if (gitResult.Error.Contains("failed to execute prompt script")) return GitPushResult.NoCredentials; return GitPushResult.Unknown; }