aboutsummaryrefslogtreecommitdiffhomepage
path: root/api/services
diff options
context:
space:
mode:
authorNick Coutsos <[email protected]>2021-11-05 21:35:48 -0400
committerNick Coutsos <[email protected]>2021-11-05 21:35:48 -0400
commit6c2db43b279b0857d1302d4af8386d98f4b62b1c (patch)
treef4bd89db949a3c1d3d87aad5dececaa35f17d2bf /api/services
parent8b2eb322a096ee3564e06c8be5dcb2302ff9ae8c (diff)
downloadkeymap-editor-6c2db43b279b0857d1302d4af8386d98f4b62b1c.tar.gz
keymap-editor-6c2db43b279b0857d1302d4af8386d98f4b62b1c.zip
Push commits to specified repo and branch
Diffstat (limited to 'api/services')
-rw-r--r--api/services/github/files.js7
1 files changed, 3 insertions, 4 deletions
diff --git a/api/services/github/files.js b/api/services/github/files.js
index 5d4b454..ddfecf8 100644
--- a/api/services/github/files.js
+++ b/api/services/github/files.js
@@ -35,7 +35,7 @@ function fetchFile (installationToken, repository, path, options = {}) {
return api.request({ url, headers, params, token: installationToken })
}
-async function commitChanges (installationId, repository, layout, keymap) {
+async function commitChanges (installationId, repository, branch, layout, keymap) {
const { data: { token: installationToken } } = await auth.createInstallationToken(installationId)
const generatedKeymap = zmk.generateKeymap(layout, keymap)
@@ -45,8 +45,7 @@ async function commitChanges (installationId, repository, layout, keymap) {
const { data: directory } = await fetchFile(installationToken, repository, 'config/')
const originalCodeKeymap = directory.find(file => file.name.toLowerCase().endsWith('.keymap'))
- const { data: repo } = await api.request({ url: `/repos/${repository}`, token: installationToken })
- const { data: [{sha, commit}] } = await api.request({ url: `/repos/${repository}/commits?per_page=1`, token: installationToken })
+ const { data: {sha, commit} } = await api.request({ url: `/repos/${repository}/commits/${branch}`, token: installationToken })
const { data: { sha: newTreeSha } } = await api.request({
url: `/repos/${repository}/git/trees`,
@@ -83,7 +82,7 @@ async function commitChanges (installationId, repository, layout, keymap) {
})
await api.request({
- url: `/repos/${repository}/git/refs/heads/${repo.default_branch}`,
+ url: `/repos/${repository}/git/refs/heads/${branch}`,
method: 'PATCH',
token: installationToken,
data: {