Fix ref and ssh_url in WebHook payloads (#3656)

This commit is contained in:
Naoki Takezoe
2024-12-19 15:19:42 +09:00
committed by GitHub
parent fdfd8ec9b2
commit b1d4a18c9b
6 changed files with 8 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ case class ApiRepository(
val url = ApiPath(s"/api/v3/repos/${full_name}")
val clone_url = ApiPath(s"/git/${full_name}.git")
val html_url = ApiPath(s"/${full_name}")
val ssh_url = Some(SshPath(""))
val ssh_url = Some(SshPath(s"/${full_name}.git"))
}
object ApiRepository {

View File

@@ -629,7 +629,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
sender,
repository,
owner,
ref = newBranchName,
ref = s"refs/heads/${newBranchName}",
refType = "branch"
)
}
@@ -1017,7 +1017,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
WebHookPushPayload(
git,
pusherAccount,
newBranchName,
s"refs/heads/${newBranchName}",
repository,
List(),
ownerAccount,
@@ -1036,7 +1036,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
sender,
repository,
owner,
ref = newBranchName,
ref = s"refs/heads/${newBranchName}",
refType = "branch"
)
}

View File

@@ -373,7 +373,7 @@ object SystemSettingsService {
if (isDefaultPort) {
s"${genericUser}@${host}"
} else {
s"${genericUser}@${host}:${port}"
s"ssh://${genericUser}@${host}:${port}"
}
def getUrl(owner: String, name: String): String =

View File

@@ -204,7 +204,7 @@ class GitBucketReceivePackFactory extends ReceivePackFactory[HttpServletRequest]
val settings = loadSystemSettings()
val baseUrl = settings.baseUrl(request)
val sshUrl = settings.sshUrl(owner, repository)
val sshUrl = settings.sshUrl
if (!repository.endsWith(".wiki")) {
val hook = new CommitLogHook(owner, repository, pusher, baseUrl, sshUrl)

View File

@@ -183,7 +183,7 @@ class DefaultGitReceivePack(owner: String, repoName: String, baseUrl: String, ss
val receive = new ReceivePack(repository)
if (!repoName.endsWith(".wiki")) {
val hook =
new CommitLogHook(owner, repoName, userName(authType), baseUrl, Some(sshAddress.getUrl(owner, repoName)))
new CommitLogHook(owner, repoName, userName(authType), baseUrl, Some(sshAddress.getUrl))
receive.setPreReceiveHook(hook)
receive.setPostReceiveHook(hook)
}

View File

@@ -90,7 +90,7 @@ class SystemSettingsServiceSpec extends AnyWordSpecLike with Matchers {
"getUrl" which {
"returns the port number when not using port 22" in new MockContext {
override val port = 8022
sshAddress.getUrl shouldBe "git@code.these.solutions:8022"
sshAddress.getUrl shouldBe "ssh://git@code.these.solutions:8022"
}
"leaves off the port number when using port 22" in new MockContext {
override val port = 22