Running git push with sys.io.Process

55 views
Skip to first unread message

Cristian Baluta

unread,
Apr 7, 2017, 3:07:57 PM4/7/17
to haxe...@googlegroups.com
Hi,

I don't seem to be able to run 'git push' command with Process
Running the command directly for the first time on a branch in Terminal i get

fatal: The current branch set_upstream has no upstream branch.

To push the current branch and set the remote as upstream, use


    git push --set-upstream origin set_upstream


If i run it through Process i get nothing and i'm not sure the command runs since has no effect.

I use:
var process = new sys.io.Process("git", ["push"]); 
process.exitCode(true);
var result = process.stdout.readAll().toString();
trace(result);

Sys.command("git", ["push"]); works but i can't get its output in haxe.
'git branch' through Process works too

Any ideas if i can run it and get its output too?
What i want is to find if a branch was set to upstream or not.

Thanks.

--

Valentin Lemière

unread,
Apr 8, 2017, 3:41:12 PM4/8/17
to Haxe
Hi,

git errors are sent on stderr; so you need to do `process.stderr.readAll().toString();`

you also can look at the value of the exit code to know if it exited with success (code 0) or with some error (code > 0)

Alternatively you can use `git branch -vv` to see the remote, or lack thereof, branch associated with the local branch.

--
Valentin
Reply all
Reply to author
Forward
0 new messages