2

I am writing a psake script. One of the tasks pulls files from a Github-hosted repository:

Framework "4.0"
$ErrorActionPreference = "stop"

formatTaskName "`n##------ {0} ------##`n"

task DeployToLocalDevelopmentEnvironment {
    # other commands

    exec { git pull origin somebranch } # this is the line that fails

    # other commands
}

pull command fails with the following message:

From https://github.com/account_name/project_name

It looks like the rest of the error message gets cut off somewhere, so I can't actually get the cause of the problem.

Any thoughts on what how I can view the full error message?

Arnold Zokas
  • 8,306
  • 6
  • 50
  • 76

2 Answers2

0

Have you tried Out-File as a log mechanism?

exec { git pull origin somebranch | Out-File C:\output.txt }

You do not need an "exec" if you perform a "git pull" in pure Powershell. Have you tried it without the "exec"? Like so:

git pull origin somebranch

I believe your problem is with PSAKE truncating your result message. Try it in pure powershell and see what is returned? I do not even know if that's possible...

D3vtr0n
  • 2,774
  • 3
  • 33
  • 53
0

Still no idea why is happening, but I have found a work-around:

$processStartInfo = new-object system.diagnostics.processStartInfo
$processStartInfo.workingDirectory = (get-location).path
$processStartInfo.fileName = "git"
$processStartInfo.arguments = "pull origin $branch_name"
$processStartInfo.useShellExecute = $false

$process = [system.diagnostics.process]::start($processStartInfo);
$process.waitForExit();

I have a theory, but can't prove it (yet):

  • There are three potential causes: powershell, psake, git
  • I was able to rule-out psake by calling git directly from powershell
  • All other command-line tools output messages correctly when called from PowerShell, so that rules-out PowerShell
  • I suspect the issue is with how git outputs messages to the console
  • The next step is to contact PowerShell team to find a proper solution. What's the best way to do that?
Arnold Zokas
  • 8,306
  • 6
  • 50
  • 76
  • If git thinks it is attached to a console then it outputs to a pager process. If you pipe the output to something else then it won't do that. You are probably getting some of the ANSI codes and breaking on that - as you don't need them you can try 'git --no-pager ....' or just pipe the output to something as suggested elsewhere. – patthoyts Dec 10 '12 at 11:48