Coder Social home page Coder Social logo

Comments (3)

fleipold avatar fleipold commented on May 19, 2024

This means that the git command returned a non zero exit code (1). Interestingly there is no error output (this would normally be included in the exception.
Unfortunately standard out is not captured in the exception. You can suppress the exception with:

result = new ProcBuilder("git")
            .withArgs("commit","-m").withArg(""+(char)34+"1st commit"+(char)34+"")
            .withExpectedExitStatuses(0, 1)
            .run();

If you then print the output like so:

System.out.println(result.getOutputString());
//now bail
if (result.getExitValue()!=0)
  throw new RuntimeException("Failed to run git");

You might see what is going wrong.

Also, you don't need to add the quotation marks to the argument. they normally tell bash that your message is a single argument, i.e. they are stripped off when the arguments are passed to the process.

from jproc.

Rupangkan avatar Rupangkan commented on May 19, 2024

@fleipold Thank you, I found out the flaw in my code. Your suggestion was beneficial.

from jproc.

fleipold avatar fleipold commented on May 19, 2024

@Rupangkan I am glad you figured it out. Thank you for this bug report. I have improved the exception message, so it now includes standard out from the failed command (available in the latest release 2.5.1), here an example:

Exception in thread "main" org.buildobjects.process.ExternalProcessFailureException: External process `git` terminated with unexpected exit status 1 after 39ms:
  $ git commit -m '1st commit'
  STDOUT: On branch master
  STDOUT:
  STDOUT: Initial commit
  STDOUT:
  STDOUT: nothing to commit (create/copy files and use "git add" to track)

from jproc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.