@boennemann/github-change-remote-files
v1.1.2
Published
create a new commit with a changed file
Downloads
8
Readme
github-change-remote-file
| | | | | | | --- | --- | --- | --- | --- |
Note: this is a temporary hack because I needed this to work real quick. It will (? should) eventually land upstream
This module allows you to change a single file in a repository on GitHub and create a new commit or pull-request from that change. This has little to no overhead, because it doesn't work with a local copy of the git repository – everything is done via the GitHub API.
Examples
Create a new commit:
githubChangeRemoteFile({
user: 'boennemann',
repo: 'animals',
filenames: ['.gitattributes', '.editorconfig']
transforms: [function (content) {
return createNewContent(content)
}, function () {
return createNewContent(content)
}],
token: '<github access token with sufficent rights>'
}, function (err, res) {
console.log(res.sha) // sha of the new commit
})
Create a new commit and send a PR:
githubChangeRemoteFile({
user: 'boennemann',
repo: 'animals',
filenames: ['.gitattributes', '.editorconfig']
transforms: [function (content) {
return createNewContent(content)
}, function () {
return createNewContent(content)
}],
token: '<github access token with sufficent rights>',
pr: {
title: 'Updated standard to latest version',
body: 'whatever'
}
}, function (err, res) {
console.log(res.html_url) // url of the pr
})
Create a new commit and push it on top of the (master) branch:
githubChangeRemoteFile({
user: 'boennemann',
repo: 'animals',
filenames: ['.gitattributes', '.editorconfig']
transforms: [function (content) {
return createNewContent(content)
}, function () {
return createNewContent(content)
}],
token: '<github access token with sufficent rights>',
push: true
}, function (err, res) {
console.log(res.object.url) // url of the new commit
})