-
-
Notifications
You must be signed in to change notification settings - Fork 108
Call to undefined method CzProject\GitPhp\Git::fetch() #93
-
Hello, I'm experimenting with this tool and I'm kind of having problems, I'm unable to figure out why, but I'm unable to do a Git::Fetch() in my codebase. I am running Laravel 10, Php 8.1, and I have the latest version of CzProject\GitPhp.
The error is
Error
Call to undefined method CzProject\GitPhp\Git::fetch()
at app\Console\Commands\utility_update_packages.php:40
36▕ foreach ($repositories as $repository) {
37▕ // Create a new GitPhp instance
38▕
39▕ // Fetch the repository
➜ 40▕ $git->fetch();
41▕
42▕ // echo it out
43▕ echo "Updated " . $repository->name . "\n";
44▕ }
1 vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
App\Console\Commands\utility_update_packages::handle()
2 vendor\laravel\framework\src\Illuminate\Container\Util.php:41
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
and the code is:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\repository;
use CzProject\GitPhp\Git;
class utility_update_packages extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'swu:update_packages';
/**
* The console command description.
*
* @var string
*/
protected $description = '';
/**
* Execute the console command.
*/
public function handle()
{
$git = new Git;
// Collect Repositories
$repositories = repository::all();
// Fetch each repository
foreach ($repositories as $repository) {
// Create a new GitPhp instance
// Fetch the repository
$git->fetch();
// echo it out
echo "Updated " . $repository->name . "\n";
}
}
}
Again I am just experimenting with it, so maybe it's wrong, I'm trying to figure it out for a larger project. Does anyone know what's going on?
Beta Was this translation helpful? Give feedback.
All reactions
Hi, this is correct error, there is no method CzProject\GitPhp\Git::fetch() - you must call this method on CzProject\GitPhp\GitRepository instance, for example:
$git = new Git; // Collect Repositories $repositories = repository::all(); // Fetch each repository foreach ($repositories as $repository) { // Create a new GitPhp instance $repo = $git->open($pathToRepository); // Fetch the repository $repo->fetch(); // echo it out echo "Updated " . $repository->name . "\n"; }
Replies: 1 comment 1 reply
-
Hi, this is correct error, there is no method CzProject\GitPhp\Git::fetch() - you must call this method on CzProject\GitPhp\GitRepository instance, for example:
$git = new Git; // Collect Repositories $repositories = repository::all(); // Fetch each repository foreach ($repositories as $repository) { // Create a new GitPhp instance $repo = $git->open($pathToRepository); // Fetch the repository $repo->fetch(); // echo it out echo "Updated " . $repository->name . "\n"; }
Beta Was this translation helpful? Give feedback.
All reactions
-
Ahh okay thanks for your help, I get a little confused sometimes as I don't know which method the "use" statement should reference.
Beta Was this translation helpful? Give feedback.