Skip to content

Git Commit Command Fails (Exit Code 1) #74

Open

Description

@dmerfeld

My code structure looks something like this:

use CzProject\GitPhp\Git;

$git = new Git;

$repo = $git->open(base_path());  // base path of local files
$repo->checkout('main');
$repo->pull('origin');

// make some changes to the local files.

// check for changes made
if ($repo->hasChanges()) {
  $repo->addAllChanges();
  $repo->commit('My Commit Message');
  $repo->push(NULL, array('--repo' => 'https://'.env('GITHUB_USER').':'.env('GITHUB_PASS').'@github.com/MyUser/MyRepo.git'));
}

I am able to read the repo, make changes, detect those changes all with success. However when I try to do a commit, I get an error. Command 'git commit -m 'My Commit Message'' failed (exit-code 1).

I've tried setting up the repo to use https and SSH, both fail at the same step. All commands continue to work in the Terminal as expected. Any thoughts on why I would get a failure on the commit command?

Activity

  1. janpecha commented on Sep 15, 2021

    @janpecha
    Member

    Hello, I don't know where can be problem but try to dump error output:

    try {
      $repo->commit('message');
    } catch (\CzProject\GitPhp\GitException $e) {
      var_dump($e->getRunnerResult()->toText());
    }

    Maybe it helps to find solution.

  2. dmerfeld commented on Sep 15, 2021

    @dmerfeld
    Author

    I'm not sure if this might be helpful but here's the output:

    string(319) "$ git commit -m message
    
    ---- STDOUT: 
    
    
    
    ---- STDERR: 
    
    dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib
      Referenced from: /usr/local/bin/node
      Reason: image not found
    .husky/pre-commit: line 4:  9262 Abort trap: 6           npm test
    husky - pre-commit hook exited with code 134 (error)
    
    => 1
    
    
  3. janpecha commented on Sep 21, 2021

    @janpecha
    Member

    It's look like problem with pre-commit hook. Unfortunately I don't know how to solve it, I don't use husky tool :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions