Skip to content

Commit

Permalink
master repo/install:301 update repo now get actually data
Browse files Browse the repository at this point in the history
  • Loading branch information
daniwe4 authored and tbongers-cat committed Mar 8, 2023
1 parent 48f5899 commit fc70796
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class App extends Application
{
const NAME = "Doil Version 20230223 - build 2023-02-23";
const NAME = "Doil Version 20230308 - build 2023-03-08";

public function __construct(Command ...$commands)
{
Expand Down
7 changes: 6 additions & 1 deletion app/src/Commands/Instances/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,12 @@ protected function checkTarget() : Closure
protected function getBranches(OutputInterface $output, string $path, string $url) : array
{
$this->writer->beginBlock($output, "Update repo $url");
$this->git->fetchBare($path, $url);
$this->git->setLocalConfig(
$path,
"remote.origin.fetch",
"refs/heads/*:refs/heads/*"
);
$this->git->fetchBare($path);
$branches = $this->git->getBranches($path);
$this->writer->endBlock();
return $branches;
Expand Down
7 changes: 6 additions & 1 deletion app/src/Commands/Repo/RepoManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ public function updateRepo(Repo $repo) : void
$repo = array_shift($repos);

if ($this->filesystem->exists($path . "/" . $repo->getName())) {
$this->git->fetchBare($path . "/" . $repo->getName(), $repo->getUrl());
$this->git->setLocalConfig(
$path . "/" . $repo->getName(),
"remote.origin.fetch",
"+refs/heads/*:refs/remotes/origin/*"
);
$this->git->fetchBare($path . "/" . $repo->getName());
return;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/Lib/Git/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
interface Git
{
public function getBranches(string $path) : array;
public function fetchBare(string $path, string $url) : void;
public function fetchBare(string $path) : void;
public function cloneBare(string $url, string $path) : void;
public function setLocalConfig(string $path, ...$commands) : void;
public function checkoutRemote(string $path, string $branch) : void;
Expand Down
8 changes: 3 additions & 5 deletions app/src/Lib/Git/GitShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@ public function getBranches(string $path) : array
"-C",
$path,
"branch",
"-a",
"--format=%(refname:short)",
];

$this->logger->info("Retrieve branches from path '$path'");
return array_filter(explode("\n", $this->run($cmd, $this->logger)));
}

public function fetchBare(string $path, string $url) : void
public function fetchBare(string $path) : void
{
$cmd = [
"git",
"-C",
$path,
"fetch",
$url
"fetch"
];

$this->logger->info("Fetch url '$url' to path '$path'");
$this->logger->info("Fetch to path '$path'");
$this->run($cmd, $this->logger);
}

Expand Down
4 changes: 2 additions & 2 deletions app/tests/Commands/Repo/RepoManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function test_updateRepo_with_already_existing_global_repo() : void
$git
->expects($this->once())
->method("fetchBare")
->with("/usr/local/share/doil/repositories/global1", "https://global1.git")
->with("/usr/local/share/doil/repositories/global1")
;

$repo_manager->updateRepo($repo);
Expand Down Expand Up @@ -244,7 +244,7 @@ public function test_updateRepo_with_already_existing_local_repo() : void
$git
->expects($this->once())
->method("fetchBare")
->with("/home/doil/.doil/repositories/local1", "https://local1.git")
->with("/home/doil/.doil/repositories/local1")
;

$repo_manager->updateRepo($repo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

source ${SCRIPT_DIR}/update.sh

doil_update_20230223() {
doil_update_20230308() {
update
return $?
}

0 comments on commit fc70796

Please sign in to comment.