mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 14:10:56 -05:00
Remove duplicated code (#1137)
* Remove duplicated code on ghe config apply * Add funciton to replace duplicated cod * Fix comment * Fix java test duplicated code * Fix python test duplicated code * Update javascript es test acording to change * Fix linters bash * Fix javascript standard linters on javascript es good
This commit is contained in:
parent
594be7e0b2
commit
5c31b85619
10 changed files with 190 additions and 390 deletions
|
@ -31,6 +31,22 @@ Header() {
|
||||||
info "-------------------------------------------------------"
|
info "-------------------------------------------------------"
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
#### Function CheckShellErrors #################################################
|
||||||
|
CheckShellErrors() {
|
||||||
|
#######################
|
||||||
|
# Load the error code #
|
||||||
|
#######################
|
||||||
|
ERROR_CODE=$?
|
||||||
|
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ $ERROR_CODE -ne 0 ]; then
|
||||||
|
error "$1"
|
||||||
|
fatal "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
#### Function CleanTestFiles ###################################################
|
#### Function CleanTestFiles ###################################################
|
||||||
CleanTestFiles() {
|
CleanTestFiles() {
|
||||||
info "-------------------------------------------------------"
|
info "-------------------------------------------------------"
|
||||||
|
@ -44,18 +60,7 @@ CleanTestFiles() {
|
||||||
find "${GITHUB_WORKSPACE}" -type f -name "*_bad_*" -o -path "*javascript_prettier*" -name "*javascript_good*" 2>&1
|
find "${GITHUB_WORKSPACE}" -type f -name "*_bad_*" -o -path "*javascript_prettier*" -name "*javascript_good*" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to get list of all files!" "ERROR:[${FIND_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to get list of all files!"
|
|
||||||
fatal "ERROR:[${FIND_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Get the directory and validate it came from tests folder #
|
# Get the directory and validate it came from tests folder #
|
||||||
|
@ -78,18 +83,7 @@ CleanTestFiles() {
|
||||||
rm -f "$FILE" 2>&1
|
rm -f "$FILE" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to remove file:[${FILE}]!" "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to remove file:[${FILE}]!"
|
|
||||||
fatal "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -107,18 +101,7 @@ CleanTestDockerFiles() {
|
||||||
find "${GITHUB_WORKSPACE}" -type f -name "*Dockerfile" 2>&1
|
find "${GITHUB_WORKSPACE}" -type f -name "*Dockerfile" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to get list of all file for Docker!" "ERROR:[${FIND_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to get list of all file for Docker!"
|
|
||||||
fatal "ERROR:[${FIND_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Get the directory and validate it came from tests folder #
|
# Get the directory and validate it came from tests folder #
|
||||||
|
@ -141,18 +124,7 @@ CleanTestDockerFiles() {
|
||||||
rm -f "$FILE" 2>&1
|
rm -f "$FILE" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to remove file:[${FILE}]!" "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to remove file:[${FILE}]!"
|
|
||||||
fatal "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -170,19 +142,7 @@ CleanSHAFolder() {
|
||||||
sudo rm -rf "${GITHUB_SHA}" 2>&1
|
sudo rm -rf "${GITHUB_SHA}" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! Failed to remove folder:[${GITHUB_SHA}]!" "ERROR:[${REMOVE_CMD}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
# Error
|
|
||||||
error "ERROR! Failed to remove folder:[${GITHUB_SHA}]!"
|
|
||||||
fatal "ERROR:[${REMOVE_CMD}]"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function RenameTestFolder #################################################
|
#### Function RenameTestFolder #################################################
|
||||||
|
@ -198,18 +158,7 @@ RenameTestFolder() {
|
||||||
mv "${TEST_FOLDER}" "${CLEAN_FOLDER}" 2>&1
|
mv "${TEST_FOLDER}" "${CLEAN_FOLDER}" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to move test folder!" "ERROR:[${RENAME_FOLDER_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to move test folder!"
|
|
||||||
fatal "ERROR:[${RENAME_FOLDER_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
#### Function CleanPowershell ##################################################
|
#### Function CleanPowershell ##################################################
|
||||||
|
@ -228,18 +177,7 @@ CleanPowershell() {
|
||||||
find "${GITHUB_WORKSPACE}" -type f -name "*.psd1" 2>&1
|
find "${GITHUB_WORKSPACE}" -type f -name "*.psd1" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to get list of all file for *.psd1!" "ERROR:[${FIND_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to get list of all file for *.psd1!"
|
|
||||||
fatal "ERROR:[${FIND_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# Get the directory and validate it came from tests folder #
|
# Get the directory and validate it came from tests folder #
|
||||||
|
@ -262,18 +200,7 @@ CleanPowershell() {
|
||||||
rm -f "$FILE" 2>&1
|
rm -f "$FILE" 2>&1
|
||||||
)
|
)
|
||||||
|
|
||||||
#######################
|
CheckShellErrors "ERROR! failed to remove file:[${FILE}]!" "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ $ERROR_CODE -ne 0 ]; then
|
|
||||||
error "ERROR! failed to remove file:[${FILE}]!"
|
|
||||||
fatal "ERROR:[${REMOVE_FILE_CMD[*]}]"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,33 @@ PROCESS_CHECK=0 # Count of times to check the process
|
||||||
########################### SUB ROUTINES BELOW #################################
|
########################### SUB ROUTINES BELOW #################################
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
|
#### Function CheckShellErrors #################################################
|
||||||
|
CheckShellErrors() {
|
||||||
|
COUNTER=$1
|
||||||
|
##############################
|
||||||
|
# Check the shell for errors #
|
||||||
|
##############################
|
||||||
|
if [ "${ERROR_CODE}" -ne 0 ]; then
|
||||||
|
error "Failed to sleep!"
|
||||||
|
error "[${SLEEP_CMD}]"
|
||||||
|
info "Will try to call apply as last effort..."
|
||||||
|
####################################
|
||||||
|
# Call config apply as last effort #
|
||||||
|
####################################
|
||||||
|
RunConfigApply
|
||||||
|
else
|
||||||
|
#####################
|
||||||
|
# Increment counter #
|
||||||
|
#####################
|
||||||
|
((COUNTER++))
|
||||||
|
##########################################
|
||||||
|
# Try to check for the pid/process again #
|
||||||
|
##########################################
|
||||||
|
$2
|
||||||
|
fi
|
||||||
|
return "$COUNTER"
|
||||||
|
}
|
||||||
|
################################################################################
|
||||||
#### Function CheckGHEPid ######################################################
|
#### Function CheckGHEPid ######################################################
|
||||||
CheckGHEPid() {
|
CheckGHEPid() {
|
||||||
##################################
|
##################################
|
||||||
|
@ -48,27 +75,7 @@ CheckGHEPid() {
|
||||||
#######################
|
#######################
|
||||||
ERROR_CODE=$?
|
ERROR_CODE=$?
|
||||||
|
|
||||||
##############################
|
PID_CHECK=CheckShellErrors "PID_CHECK" "CheckGHEPid"
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
|
||||||
error "Failed to sleep!"
|
|
||||||
error "[${SLEEP_CMD}]"
|
|
||||||
info "Will try to call apply as last effort..."
|
|
||||||
####################################
|
|
||||||
# Call config apply as last effort #
|
|
||||||
####################################
|
|
||||||
RunConfigApply
|
|
||||||
else
|
|
||||||
#####################
|
|
||||||
# Increment counter #
|
|
||||||
#####################
|
|
||||||
((PID_CHECK++))
|
|
||||||
##################################
|
|
||||||
# Try to check for the pid again #
|
|
||||||
##################################
|
|
||||||
CheckGHEPid
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -111,27 +118,7 @@ CheckGHEProcess() {
|
||||||
#######################
|
#######################
|
||||||
ERROR_CODE=$?
|
ERROR_CODE=$?
|
||||||
|
|
||||||
##############################
|
PROCESS_CHECK=CheckShellErrors "PROCESS_CHECK" "CheckGHEProcess"
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
|
||||||
error "Failed to sleep!"
|
|
||||||
error "[${SLEEP_CMD}]"
|
|
||||||
info "Will try to call apply as last effort..."
|
|
||||||
####################################
|
|
||||||
# Call config apply as last effort #
|
|
||||||
####################################
|
|
||||||
RunConfigApply
|
|
||||||
else
|
|
||||||
#####################
|
|
||||||
# Increment counter #
|
|
||||||
#####################
|
|
||||||
((PROCESS_CHECK++))
|
|
||||||
######################################
|
|
||||||
# Try to check for the process again #
|
|
||||||
######################################
|
|
||||||
CheckGHEProcess
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
var http = require('http')
|
var http = require('http')
|
||||||
var createHandler = require('github-webhook-handler')
|
var createHandler = require('github-webhook-handler')
|
||||||
|
|
||||||
var handler = createHandler( { path : /webhook, secret : (process.env.SECRET) })
|
var handler = createHandler({
|
||||||
|
path: /webhook, secret : (process.env.SECRET) })
|
||||||
|
|
||||||
var userArray = ['user1']
|
var userArray = ['user1']
|
||||||
here is some garbage = that
|
here is some garbage = that
|
||||||
|
@ -70,19 +71,6 @@ function getTeamID (org) {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
if (item.name === teamName) {
|
|
||||||
teamId = item.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error, (error) => {
|
req.on('error, (error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -203,20 +191,6 @@ function getRepositories (org) {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
orgRepos.push(item.full_name)
|
|
||||||
|
|
||||||
console.log(item.full_name)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error', (error) => {
|
req.on('error', (error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
var http = require('http')
|
const http = require('http')
|
||||||
var createHandler = require('github-webhook-handler')
|
const createHandler = require('github-webhook-handler')
|
||||||
var handler = createHandler({ path: '/webhook', secret: (process.env.SECRET) })
|
const handler = createHandler({ path: '/webhook', secret: (process.env.SECRET) })
|
||||||
|
|
||||||
var userArray = ['user1']
|
const userArray = ['user1']
|
||||||
|
|
||||||
var teamDescription = 'Team of Robots'
|
const teamDescription = 'Team of Robots'
|
||||||
var teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here
|
const teamPrivacy = 'closed' // closed (visible) / secret (hidden) are options here
|
||||||
|
|
||||||
var teamName = process.env.GHES_TEAM_NAME
|
const teamName = process.env.GHES_TEAM_NAME
|
||||||
var teamAccess = 'pull' // pull,push,admin options here
|
const teamAccess = 'pull' // pull,push,admin options here
|
||||||
var teamId = ''
|
const teamId = ''
|
||||||
|
|
||||||
var orgRepos = []
|
|
||||||
|
|
||||||
// var creator = ""
|
// var creator = ""
|
||||||
|
|
||||||
|
@ -31,8 +29,6 @@ handler.on('repository', function (event) {
|
||||||
if (event.payload.action === 'created') {
|
if (event.payload.action === 'created') {
|
||||||
const repo = event.payload.repository.full_name
|
const repo = event.payload.repository.full_name
|
||||||
console.log(repo)
|
console.log(repo)
|
||||||
const org = event.payload.repository.owner.login
|
|
||||||
getTeamID(org)
|
|
||||||
setTimeout(checkTeamIDVariable, 1000)
|
setTimeout(checkTeamIDVariable, 1000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -41,51 +37,13 @@ handler.on('team', function (event) {
|
||||||
// TODO user events such as being removed from team or org
|
// TODO user events such as being removed from team or org
|
||||||
if (event.payload.action === 'deleted') {
|
if (event.payload.action === 'deleted') {
|
||||||
// const name = event.payload.team.name
|
// const name = event.payload.team.name
|
||||||
const org = event.payload.organization.login
|
|
||||||
getRepositories(org)
|
|
||||||
setTimeout(checkReposVariable, 5000)
|
setTimeout(checkReposVariable, 5000)
|
||||||
} else if (event.payload.action === 'removed_from_repository') {
|
} else if (event.payload.action === 'removed_from_repository') {
|
||||||
const org = event.payload.organization.login
|
|
||||||
getTeamID(org)
|
|
||||||
// const repo = event.payload.repository.full_name
|
// const repo = event.payload.repository.full_name
|
||||||
setTimeout(checkTeamIDVariable, 1000)
|
setTimeout(checkTeamIDVariable, 1000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function getTeamID (org) {
|
|
||||||
const https = require('https')
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
hostname: (process.env.GHE_HOST),
|
|
||||||
port: 443,
|
|
||||||
path: '/api/v3/orgs/' + org + '/teams',
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
if (item.name === teamName) {
|
|
||||||
teamId = item.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error', (error) => {
|
|
||||||
console.error(error)
|
|
||||||
})
|
|
||||||
|
|
||||||
req.end()
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkTeamIDVariable (repo) {
|
function checkTeamIDVariable (repo) {
|
||||||
if (typeof teamId !== 'undefined') {
|
if (typeof teamId !== 'undefined') {
|
||||||
addTeamToRepo(repo, teamId)
|
addTeamToRepo(repo, teamId)
|
||||||
|
@ -143,8 +101,7 @@ function reCreateTeam (org) {
|
||||||
name: teamName,
|
name: teamName,
|
||||||
description: teamDescription,
|
description: teamDescription,
|
||||||
privacy: teamPrivacy,
|
privacy: teamPrivacy,
|
||||||
maintainers: userArray,
|
maintainers: userArray
|
||||||
repo_names: orgRepos
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -178,38 +135,3 @@ function reCreateTeam (org) {
|
||||||
req.write(data)
|
req.write(data)
|
||||||
req.end()
|
req.end()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRepositories (org) {
|
|
||||||
orgRepos = []
|
|
||||||
|
|
||||||
const https = require('https')
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
hostname: (process.env.GHE_HOST),
|
|
||||||
port: 443,
|
|
||||||
path: '/api/v3/orgs/' + org + '/repos',
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
Authorization: 'token ' + (process.env.GHE_TOKEN),
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
orgRepos.push(item.full_name)
|
|
||||||
console.log(item.full_name)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error', (error) => {
|
|
||||||
console.error(error)
|
|
||||||
})
|
|
||||||
|
|
||||||
req.end()
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,6 +2,6 @@ TAP version 13
|
||||||
1..2
|
1..2
|
||||||
not ok 1 - javascript_bad_1.js
|
not ok 1 - javascript_bad_1.js
|
||||||
---
|
---
|
||||||
message: \n/tmp/lint/.automation/test/javascript_es/javascript_bad_1.js\n 4 39 error Parsing error Unterminated regular expression literal\n\n✖ 1 problem (1 error, 0 warnings)\n
|
message: \n/tmp/lint/.automation/test/javascript_es/javascript_bad_1.js\n 5 9 error Parsing error Unterminated regular expression literal\n\n✖ 1 problem (1 error, 0 warnings)\n
|
||||||
...
|
...
|
||||||
ok 2 - javascript_good_1.js
|
ok 2 - javascript_good_1.js
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
var http = require('http')
|
var http = require('http')
|
||||||
var createHandler = require('github-webhook-handler')
|
var createHandler = require('github-webhook-handler')
|
||||||
|
|
||||||
var handler = createHandler( { path : /webhook, secret : (process.env.SECRET) })
|
var handler = createHandler({
|
||||||
|
path: /webhook, secret : (process.env.SECRET) })
|
||||||
|
|
||||||
var userArray = ['user1']
|
var userArray = ['user1']
|
||||||
here is some garbage = that
|
here is some garbage = that
|
||||||
|
@ -70,19 +71,6 @@ function getTeamID (org) {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
if (item.name === teamName) {
|
|
||||||
teamId = item.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error, (error) => {
|
req.on('error, (error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
@ -203,20 +191,6 @@ function getRepositories (org) {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let body = []
|
|
||||||
const req = https.request(options, (res) => {
|
|
||||||
res.on('data', (chunk) => {
|
|
||||||
body.push(chunk)
|
|
||||||
|
|
||||||
}).on('end', () => {
|
|
||||||
body = JSON.parse(Buffer.concat(body))
|
|
||||||
body.forEach(item => {
|
|
||||||
orgRepos.push(item.full_name)
|
|
||||||
|
|
||||||
console.log(item.full_name)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
req.on('error', (error) => {
|
req.on('error', (error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
|
@ -26,6 +26,12 @@ headers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_request(query, query_variables):
|
||||||
|
payload = {"query": query, "variables": query_variables}
|
||||||
|
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def create_label(repo_id, label):
|
def create_label(repo_id, label):
|
||||||
"""
|
"""
|
||||||
Create label in the supplied repo.
|
Create label in the supplied repo.
|
||||||
|
@ -51,8 +57,7 @@ def create_label(repo_id, label):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
|
||||||
print("Created label {label}".format(label=label["name"]))
|
print("Created label {label}".format(label=label["name"]))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -78,8 +83,7 @@ def get_labels(owner, repo):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables)
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
|
||||||
|
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
|
@ -26,6 +26,12 @@ headers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_request(query, query_variables):
|
||||||
|
payload = {"query": query, "variables": query_variables}
|
||||||
|
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def create_label(repo_id, label):
|
def create_label(repo_id, label):
|
||||||
"""
|
"""
|
||||||
Create label in the supplied repo.
|
Create label in the supplied repo.
|
||||||
|
@ -51,8 +57,7 @@ def create_label(repo_id, label):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
|
||||||
print("Created label {label}".format(label=label["name"]))
|
print("Created label {label}".format(label=label["name"]))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -78,8 +83,7 @@ def get_labels(owner, repo):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
|
||||||
|
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
|
@ -26,6 +26,12 @@ headers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_request(query, query_variables):
|
||||||
|
payload = {"query": query, "variables": query_variables}
|
||||||
|
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def create_label(repo_id, label):
|
def create_label(repo_id, label):
|
||||||
"""
|
"""
|
||||||
Create label in the supplied repo.
|
Create label in the supplied repo.
|
||||||
|
@ -51,8 +57,7 @@ def create_label(repo_id, label):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
|
||||||
print("Created label {label}".format(label=label["name"]))
|
print("Created label {label}".format(label=label["name"]))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -78,8 +83,7 @@ def get_labels(owner, repo):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
|
||||||
|
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
|
@ -26,6 +26,12 @@ headers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_request(query, query_variables):
|
||||||
|
payload = {"query": query, "variables": query_variables}
|
||||||
|
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def create_label(repo_id, label):
|
def create_label(repo_id, label):
|
||||||
"""
|
"""
|
||||||
Create label in the supplied repo.
|
Create label in the supplied repo.
|
||||||
|
@ -51,8 +57,7 @@ def create_label(repo_id, label):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers).json()
|
|
||||||
print("Created label {label}".format(label=label["name"]))
|
print("Created label {label}".format(label=label["name"]))
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -78,8 +83,7 @@ def get_labels(owner, repo):
|
||||||
) as query_file:
|
) as query_file:
|
||||||
query = "".join(query_file.readlines())
|
query = "".join(query_file.readlines())
|
||||||
|
|
||||||
payload = {"query": query, "variables": query_variables}
|
response = make_request(query, query_variables).json()
|
||||||
response = requests.post(api_url, data=json.dumps(payload), headers=headers)
|
|
||||||
|
|
||||||
status_code = response.status_code
|
status_code = response.status_code
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
Loading…
Reference in a new issue