Skip to content

Commit

Permalink
Fix indentation
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Jan 10, 2023
1 parent 49fb949 commit 2a202e9
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 143 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"indent": ["error", 4]
}
}
56 changes: 28 additions & 28 deletions GitForWindowsHelper/azure-pipelines.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,24 @@ const getRelease = async (context, token, organization, project, releaseId) => {
}

const createRelease = async (
context,
token,
organization,
project,
releaseDefinitionId,
artifactAlias,
artifactBuildRunId,
artifactBuildRunName,
artifactBuildDefinitionId,
artifactBuildDefinitionName,
sourceBranch,
sourceCommitId,
repo
context,
token,
organization,
project,
releaseDefinitionId,
artifactAlias,
artifactBuildRunId,
artifactBuildRunName,
artifactBuildDefinitionId,
artifactBuildDefinitionName,
sourceBranch,
sourceCommitId,
repo
) => {
const auth = Buffer.from("PAT:" + token).toString("base64");
const headers = {
Accept: "application/json; api-version=7.0; excludeUrls=true",
Authorization: "Basic " + auth,
Accept: "application/json; api-version=7.0; excludeUrls=true",
Authorization: "Basic " + auth,
};
const body = {
definitionId: releaseDefinitionId,
Expand Down Expand Up @@ -157,19 +157,19 @@ const releaseGitArtifacts = async (context, prNumber) => {

const token = process.env['AZURE_PIPELINE_TRIGGER_TOKEN']
const answer2 = await createRelease(
context,
token,
'git-for-windows',
'git',
1,
'artifacts',
artifactBuildRunId,
artifactBuildRunName,
artifactBuildDefinitionId,
artifactBuildDefinitionName,
sourceBranch,
sourceCommitId,
'git-for-windows/git'
context,
token,
'git-for-windows',
'git',
1,
'artifacts',
artifactBuildRunId,
artifactBuildRunName,
artifactBuildDefinitionId,
artifactBuildDefinitionName,
sourceBranch,
sourceCommitId,
'git-for-windows/git'
)
return {
id: answer2.id,
Expand Down
90 changes: 45 additions & 45 deletions GitForWindowsHelper/check-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,64 @@ const queueCheckRun = async (context, token, owner, repo, ref, checkRunName, tit
const githubApiRequest = require('./github-api-request')
// is there an existing check-run we can re-use?
const { check_runs } = await githubApiRequest(
context,
token,
'GET',
`/repos/${owner}/${repo}/commits/${ref}/check-runs`
context,
token,
'GET',
`/repos/${owner}/${repo}/commits/${ref}/check-runs`
)
const filtered = check_runs
.filter(e => e.name === checkRunName && e.conclusion === null).map(e => {
return {
id: e.id,
status: e.status
}
})
.filter(e => e.name === checkRunName && e.conclusion === null).map(e => {
return {
id: e.id,
status: e.status
}
})
if (filtered.length > 0) {
// ensure that the check_run is set to status "in progress"
if (filtered[0].status !== 'queued') {
console.log(await githubApiRequest(
context,
token,
'PATCH',
`/repos/${owner}/${repo}/check-runs/${filtered[0].id}`, {
status: 'queued'
}
))
}
process.stderr.write(`Returning existing ${filtered[0].id}`)
return filtered[0].id
// ensure that the check_run is set to status "in progress"
if (filtered[0].status !== 'queued') {
console.log(await githubApiRequest(
context,
token,
'PATCH',
`/repos/${owner}/${repo}/check-runs/${filtered[0].id}`, {
status: 'queued'
}
))
}
process.stderr.write(`Returning existing ${filtered[0].id}`)
return filtered[0].id
}

const { id } = await githubApiRequest(
context,
token,
'POST',
`/repos/${owner}/${repo}/check-runs`, {
name: checkRunName,
head_sha: ref,
status: 'queued',
output: {
title,
summary
context,
token,
'POST',
`/repos/${owner}/${repo}/check-runs`, {
name: checkRunName,
head_sha: ref,
status: 'queued',
output: {
title,
summary
}
}
}
)
return id
}
}

const updateCheckRun = async (context, token, owner, repo, checkRunId, parameters) => {
const updateCheckRun = async (context, token, owner, repo, checkRunId, parameters) => {
const githubApiRequest = require('./github-api-request')

await githubApiRequest(
context,
token,
'PATCH',
`/repos/${owner}/${repo}/check-runs/${checkRunId}`,
parameters
await githubApiRequest(
context,
token,
'PATCH',
`/repos/${owner}/${repo}/check-runs/${checkRunId}`,
parameters
)
}
}

module.exports = {
module.exports = {
queueCheckRun,
updateCheckRun
}
}
32 changes: 16 additions & 16 deletions GitForWindowsHelper/get-collaborator-permissions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Gets the permission level of a collaborator on the specified repository
// Returns `ADMIN`, `MAINTAIN`, `READ`, `TRIAGE` or `WRITE`.
module.exports = async (context, token, owner, repo, collaborator) => {
const gitHubAPIRequest = require('./github-api-request')
const answer = await gitHubAPIRequest(
context,
token,
'POST',
'/graphql', {
query: `query CollaboratorPermission($owner: String!, $repo: String!, $collaborator: String) {
const gitHubAPIRequest = require('./github-api-request')
const answer = await gitHubAPIRequest(
context,
token,
'POST',
'/graphql', {
query: `query CollaboratorPermission($owner: String!, $repo: String!, $collaborator: String) {
repository(owner:$owner, name:$repo) {
collaborators(query: $collaborator) {
edges {
Expand All @@ -16,13 +16,13 @@ module.exports = async (context, token, owner, repo, collaborator) => {
}
}
}`,
variables: {
owner,
repo,
collaborator
}
}
)
if (answer.error) throw answer.error
return answer.data.repository.collaborators.edges.map(e => e.permission.toString())
variables: {
owner,
repo,
collaborator
}
}
)
if (answer.error) throw answer.error
return answer.data.repository.collaborators.edges.map(e => e.permission.toString())
}
2 changes: 1 addition & 1 deletion GitForWindowsHelper/github-api-request-as-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = async (context, requestMethod, requestPath, body) => {
}

const toBase64 = (obj) => Buffer.from(JSON.stringify(obj), "utf-8").toString("base64url")
const headerAndPayload = `${toBase64(header)}.${toBase64(payload)}`
const headerAndPayload = `${toBase64(header)}.${toBase64(payload)}`

const privateKey = `-----BEGIN RSA PRIVATE KEY-----\n${process.env['GITHUB_APP_PRIVATE_KEY']}\n-----END RSA PRIVATE KEY-----\n`

Expand Down
2 changes: 1 addition & 1 deletion GitForWindowsHelper/https-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = async (context, hostname, method, requestPath, body, headers) =
statusCode: res.statusCode,
statusMessage: res.statusMessage,
headers: res.headers
})
})

const chunks = []
res.on('data', data => chunks.push(data))
Expand Down
36 changes: 18 additions & 18 deletions GitForWindowsHelper/slash-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ module.exports = async (context, req) => {
if (alreadyOpenedPR.length > 0) {
({ html_url: commentURL, id: commentId } =
await appendToIssueComment(
context,
await getToken(),
owner,
repo,
commentId,
`${
packageType ? `${packageType} ` : ""
}PR [already exists](${alreadyOpenedPR[0].html_url})`
context,
await getToken(),
owner,
repo,
commentId,
`${
packageType ? `${packageType} ` : ""
}PR [already exists](${alreadyOpenedPR[0].html_url})`
));
return
}
Expand Down Expand Up @@ -111,14 +111,14 @@ module.exports = async (context, req) => {
|| !req.body.issue.pull_request
|| !['build-extra', 'MINGW-packages', 'MSYS2-packages'].includes(repo)) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}
}

await checkPermissions()

const { guessComponentUpdateDetails, isMSYSPackage } = require('./component-updates')
const { package_name } = deployMatch[2]
? { package_name: deployMatch[2] }
: guessComponentUpdateDetails(req.body.issue.title, req.body.issue.body)
? { package_name: deployMatch[2] }
: guessComponentUpdateDetails(req.body.issue.title, req.body.issue.body)

// The commit hash of the tip commit is sadly not part of the
// "comment.created" webhook's payload. Therefore, we have to get it
Expand Down Expand Up @@ -238,9 +238,9 @@ module.exports = async (context, req) => {
if (owner !== 'git-for-windows'
|| repo !== 'git'
|| !req.body.issue.pull_request
) {
) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}
}

await checkPermissions()
await thumbsUp()
Expand All @@ -255,11 +255,11 @@ module.exports = async (context, req) => {

if (command == '/release') {
if (owner !== 'git-for-windows'
|| repo !== 'git'
|| !req.body.issue.pull_request
) {
|| repo !== 'git'
|| !req.body.issue.pull_request
) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}
}

await checkPermissions()
await thumbsUp()
Expand All @@ -277,7 +277,7 @@ module.exports = async (context, req) => {
if (owner !== 'git-for-windows'
|| !['git', 'build-extra', 'MINGW-packages', 'MSYS2-packages'].includes(repo)) {
return `Ignoring ${command} in unexpected repo: ${commentURL}`
}
}

await checkPermissions()

Expand Down
Loading

0 comments on commit 2a202e9

Please sign in to comment.