Skip to content

Commit

Permalink
Merge pull request #43 from salahhusa9/git-checkout-throw-away-local-…
Browse files Browse the repository at this point in the history
…modifications

Git checkout throw away local modifications
  • Loading branch information
salahhusa9 committed Apr 1, 2024
2 parents 81d8f5c + f48c468 commit 257143f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Helpers/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static function pull()
*/
public static function checkout($branch)
{
$process = Process::run(self::gitPath().' checkout '.$branch);
$process = Process::run(self::gitPath().' checkout '.$branch.' -f');

if ($process->failed()) {
throw new GitFailedException('this command failed: '.$process->command().' with message: '.$process->errorOutput());
Expand Down
4 changes: 2 additions & 2 deletions tests/GitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function test_git_pull_failed(): void
public function test_git_checkout(): void
{
Process::fake([
'git checkout branch-name' => Process::result(''),
'git checkout branch-name -f' => Process::result(''),
]);

config()->set('updater.git_path', 'git');
Expand All @@ -184,7 +184,7 @@ public function test_git_checkout_failed(): void
$this->expectExceptionMessage('Test error output');

Process::fake([
'git checkout branch-name' => Process::result(
'git checkout branch-name -f' => Process::result(
output: 'Test output',
errorOutput: 'Test error output',
exitCode: 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/UpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testUpdate()
'git rev-parse --abbrev-ref HEAD' => 'HEAD',
'git describe --tags --abbrev=0' => '1.0.0',
'git pull' => '',
'git checkout 1.0.1' => 'TEST',
'git checkout 1.0.1 -f' => 'TEST',
'git remote set-url origin https://salahhusa9:salahhusa9@github.com/salahhusa9/laravel-test.git' => '',
'git fetch' => '',
]);
Expand All @@ -162,7 +162,7 @@ public function testUpdate()
'git rev-parse --abbrev-ref HEAD' => 'HEAD',
'git describe --tags --abbrev=0' => '1.0.0',
'git pull origin HEAD' => '',
'git checkout 1.0.1' => '...',
'git checkout 1.0.1 -f' => '...',
'git remote set-url origin https://salahhusa9:salahhusa9@github.com/salahhusa9/laravel-test.git' => '',
'git fetch' => '',
]);
Expand Down

0 comments on commit 257143f

Please sign in to comment.