public void GetCurrentRevision_should_return_null_if_bare_or_empty_repo() { // bare repo has no current checkout, empty repo has no commits _module.GetRevision(shortFormat: true, loadRefs: true).Returns(x => null); var result = ScriptOptionsParser.GetTestAccessor() .GetCurrentRevision(module: _module, currentTags: null, currentLocalBranches: null, currentRemoteBranches: null, currentBranches: null, loadBody: false); result.Should().Be(null); }
private static GitRevision GetCurrentRevision( [NotNull] IGitModule module, List <IGitRef> currentTags, List <IGitRef> currentLocalBranches, List <IGitRef> currentRemoteBranches, List <IGitRef> currentBranches, bool loadBody) { GitRevision currentRevision; IEnumerable <IGitRef> refs; currentRevision = module.GetRevision(shortFormat: !loadBody, loadRefs: true); refs = currentRevision?.Refs ?? Array.Empty <IGitRef>(); foreach (var gitRef in refs) { if (gitRef.IsTag) { currentTags.Add(gitRef); } else if (gitRef.IsHead || gitRef.IsRemote) { currentBranches.Add(gitRef); if (gitRef.IsRemote) { currentRemoteBranches.Add(gitRef); } else { currentLocalBranches.Add(gitRef); } } } return(currentRevision); }
public void RunScript_with_arguments_with_c_option_shall_succeed() { _exampleScript.Command = "cmd"; _exampleScript.Arguments = "/c echo {cHash}"; var revision = new GitRevision(ObjectId.IndexId); _module.GetRevision(shortFormat: true, loadRefs: true).Returns(x => revision); var result = ScriptRunner.RunScript(null, _module, _keyOfExampleScript, uiCommands: null, revisionGrid: null); result.Should().BeEquivalentTo(new CommandStatus(true, needsGridRefresh: false)); }