Skip to content

Commit d4032cc

Browse files
committed
refactor: Make createFile and createBranch abstract in Git class
1 parent 2f5fa1c commit d4032cc

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

src/VCS/Adapter/Git.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Utopia\VCS\Adapter;
66
use Utopia\Cache\Cache;
7-
use Exception;
87

98
abstract class Git extends Adapter
109
{
@@ -35,20 +34,18 @@ public function getType(): string
3534
{
3635
return self::TYPE_GIT;
3736
}
37+
3838
/**
39-
* Create a file in a repository
40-
*
41-
* @param string $owner Owner of the repository
42-
* @param string $repositoryName Name of the repository
43-
* @param string $filepath Path where file should be created
44-
* @param string $content Content of the file
45-
* @param string $message Commit message
46-
* @return array<mixed> Response from API
47-
*/
48-
public function createFile(string $owner, string $repositoryName, string $filepath, string $content, string $message = 'Add file'): array
49-
{
50-
throw new Exception("Not implemented");
51-
}
39+
* Create a file in a repository
40+
*
41+
* @param string $owner Owner of the repository
42+
* @param string $repositoryName Name of the repository
43+
* @param string $filepath Path where file should be created
44+
* @param string $content Content of the file
45+
* @param string $message Commit message
46+
* @return array<mixed> Response from API
47+
*/
48+
abstract public function createFile(string $owner, string $repositoryName, string $filepath, string $content, string $message = 'Add file'): array;
5249

5350
/**
5451
* Create a branch in a repository
@@ -59,8 +56,5 @@ public function createFile(string $owner, string $repositoryName, string $filepa
5956
* @param string $oldBranchName Name of the branch to branch from
6057
* @return array<mixed> Response from API
6158
*/
62-
public function createBranch(string $owner, string $repositoryName, string $newBranchName, string $oldBranchName): array
63-
{
64-
throw new Exception("Not implemented");
65-
}
59+
abstract public function createBranch(string $owner, string $repositoryName, string $newBranchName, string $oldBranchName): array;
6660
}

src/VCS/Adapter/Git/GitHub.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,35 @@ public function createRepository(string $owner, string $repositoryName, bool $pr
9494
return $response['body'] ?? [];
9595
}
9696

97+
/**
98+
* Create a file in a repository
99+
*
100+
* @param string $owner Owner of the repository
101+
* @param string $repositoryName Name of the repository
102+
* @param string $filepath Path where file should be created
103+
* @param string $content Content of the file
104+
* @param string $message Commit message
105+
* @return array<mixed> Response from API
106+
*/
107+
public function createFile(string $owner, string $repositoryName, string $filepath, string $content, string $message = 'Add file'): array
108+
{
109+
throw new Exception("Not implemented");
110+
}
111+
112+
/**
113+
* Create a branch in a repository
114+
*
115+
* @param string $owner Owner of the repository
116+
* @param string $repositoryName Name of the repository
117+
* @param string $newBranchName Name of the new branch
118+
* @param string $oldBranchName Name of the branch to branch from
119+
* @return array<mixed> Response from API
120+
*/
121+
public function createBranch(string $owner, string $repositoryName, string $newBranchName, string $oldBranchName): array
122+
{
123+
throw new Exception("Not implemented");
124+
}
125+
97126
/**
98127
* Search repositories for GitHub App
99128
* @param string $installationId ID of the installation

0 commit comments

Comments
 (0)