mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
edfca74ede
Refactors file system of platforms and adds test to ensure GitHub and GitLab have same module.exports signatures.
49 lines
900 B
JavaScript
49 lines
900 B
JavaScript
const get = require('./gl-got-wrapper');
|
|
|
|
module.exports = {
|
|
createFile,
|
|
updateFile,
|
|
};
|
|
|
|
async function createFile(
|
|
repoName,
|
|
branchName,
|
|
filePath,
|
|
fileContents,
|
|
message
|
|
) {
|
|
const opts = {};
|
|
const url = `projects/${repoName}/repository/files/${filePath.replace(
|
|
/\//g,
|
|
'%2F'
|
|
)}`;
|
|
opts.body = {
|
|
branch: branchName,
|
|
commit_message: message,
|
|
encoding: 'base64',
|
|
content: Buffer.from(fileContents).toString('base64'),
|
|
};
|
|
await get.post(url, opts);
|
|
}
|
|
|
|
async function updateFile(
|
|
repoName,
|
|
branchName,
|
|
filePath,
|
|
fileContents,
|
|
message
|
|
) {
|
|
const opts = {};
|
|
const url = `projects/${repoName}/repository/files/${filePath.replace(
|
|
/\//g,
|
|
'%2F'
|
|
)}`;
|
|
opts.body = {
|
|
branch: branchName,
|
|
commit_message: message,
|
|
encoding: 'base64',
|
|
content: Buffer.from(fileContents).toString('base64'),
|
|
};
|
|
|
|
await get.put(url, opts);
|
|
}
|