You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-28Lines changed: 43 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
3
3
Rename your default branch on GitHub easily. By default it renames `master` to `main`, but is configurable using the `--new` and `--old` flags.
4
4
5
-
If provided with an `--org` argument, it will run on all repositories within that organisation. Alternatively, you can provide a `--repo` argument to edit a single repo.
5
+
If provided with an `--org`, `--user` or (`--org` and `--team`) arguments, it will run on all repositories owned by that org, user or team. Alternatively, you can provide a `--repo` argument to edit a single repo. See [Usage](#usage) for more examples.
6
6
7
7
For each repo, this tool will:
8
8
9
9
- Create a new branch at the same commit SHA as the old one
10
10
- Update all open pull requests to point at the new branch
11
11
- Update the default branch for the repo
12
12
- Delete the old branch
13
-
- Update [known URL patterns](https://github.com/mheap/github-default-branch/blob/main/src/update-content.js) in source files
13
+
- Update [known URL patterns](https://github.com/mheap/github-default-branch/tree/main/replacements) in source files
14
14
- Update any branch protections for `$old` to `$new`. (This does **not** work with patterns, it has to be an exact match)
| --confirm | Run without prompting for confirmation | false |
71
+
72
+
## Skipping transforms
73
+
74
+
You might want to skip any of the available transforms (such as deleting the old branch). You can add `--skip-[transform-name]` to disable the transform e.g. `--skip-delete-old-branch`.
Part of this script checks for the existence of files and updates their contents. Replacements are the mechanism for these updates.
75
94
76
95
### How it Works
77
96
78
-
Each .js file in the src/replacements folder is given a chance to run during the content updating step of the script. Each file in src/replacements is expected to export a function, that function receives all of the options that are available to the outmost script.
97
+
Each .js file in the `replacements` folder is given a chance to run during the content updating step of the script. Each file in replacements is expected to export a function, that function receives all of the options that are available to the outmost script.
79
98
80
99
If there is nothing to replace, then the script moves on to the next replacement.
81
100
82
101
### How to Add a Replacement
83
102
84
-
Add a file to src/replacements with a .js extension
103
+
Add a file to `replacements` with a .js extension
85
104
86
105
Like this:
87
106
@@ -100,20 +119,16 @@ module.exports = function ({
100
119
path:"<path to file in repo>",
101
120
replacements: [
102
121
{
103
-
from:"<from pattern>",
104
-
to:"<to pattern>",
122
+
from:"<from string>",
123
+
to:"<to string>",
105
124
},
106
125
{
107
-
from:"<from pattern>",
108
-
to:"<to pattern>",
126
+
from:"<from string>",
127
+
to:"<to string>",
109
128
},
110
129
],
111
130
};
112
131
};
113
132
```
114
133
115
134
The file with the path in your repo will have any line matching `from` be swapped out with `to`
116
-
117
-
### Known Issues
118
-
119
-
The replacement system gives you octokit, that's great! Unfortunately replacement functions do not currently support asynchronous calls, that's bad.
0 commit comments