Skip to content

Commit 13b2ccf

Browse files
committed
Update README.md
1 parent 5a44e84 commit 13b2ccf

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ npm install octokit-commit-multiple-files --save
1010

1111
## Usage
1212

13-
This plugin accepts `owner`, `repo`, `path`, `branch` and `message` like `.createOrUpdateFile` ([Octokit Docs](https://octokit.github.io/rest.js/#octokit-routes-repos-create-or-update-file)).
13+
This plugin accepts `owner`, `repo`, `path` and `branch` like `.createOrUpdateFile` ([Octokit Docs](https://octokit.github.io/rest.js/#octokit-routes-repos-create-or-update-file)).
1414

1515
If the `branch` provided does not exist, the plugin will error. To automatically create it, set `createBranch` to true. You may provide a `base` branch if you choose to do this, or the plugin will use the repo's default branch as the base.
1616

17-
In addition, it accepts `changes` which is an array of objects containing a `path` and the file `contents`.
17+
In addition, it accepts `changes` which is an array of objects containing a `message` and a `files` object
1818

1919
```javascript
2020
const Octokit = require("@octokit/rest").plugin(
@@ -27,17 +27,39 @@ const branchName = await octokit.repos.createOrUpdateFiles({
2727
repo,
2828
branch,
2929
createBranch,
30-
message,
3130
changes: [
3231
{
33-
path: "test.md",
34-
contents: "One"
32+
message: "Your commit message",
33+
files: {
34+
"test.md": `# This is a test
35+
36+
I hope it works`,
37+
"test2.md": {
38+
contents: `Something else`
39+
}
40+
}
3541
},
3642
{
37-
path: "test2.md",
38-
contents: "Two"
43+
"message": "This is a separate commit",
44+
"files": {
45+
"second.md": "Where should we go today?"
46+
}
3947
}
4048
]
4149
})
4250
```
4351

52+
In addition, you can set the `mode` of a file change. For example, if you wanted to update a submodule pointer:
53+
54+
```javascript
55+
{
56+
"message": "This is a submodule commit",
57+
"files": {
58+
"my_submodule": {
59+
"contents": "your-commit-sha",
60+
"mode": "160000",
61+
"type": "commit"
62+
}
63+
}
64+
}
65+
```

0 commit comments

Comments
 (0)