|
20 | 20 | ApiKeyFile = "github_api_token" |
21 | 21 | ApiTokenEnvironmentVariable = "NIMBLE_GITHUB_API_TOKEN" |
22 | 22 | ReposUrl = "https://api.github.com/repos/" |
| 23 | + defaultBranch = "master" # Default branch on https://github.com/nim-lang/packages |
23 | 24 |
|
24 | 25 | proc userAborted() = |
25 | 26 | raise newException(NimbleError, "User aborted the process.") |
@@ -101,7 +102,7 @@ proc createPullRequest(a: Auth, packageName, branch: string): string = |
101 | 102 | display("Info", "Creating PR", priority = HighPriority) |
102 | 103 | var body = a.http.postContent(ReposUrl & "nim-lang/packages/pulls", |
103 | 104 | body="""{"title": "Add package $1", "head": "$2:$3", |
104 | | - "base": "master"}""" % [packageName, a.user, branch]) |
| 105 | + "base": "$4"}""" % [packageName, a.user, branch, defaultBranch]) |
105 | 106 | var pr = parseJson(body) |
106 | 107 | return pr{"html_url"}.getStr() |
107 | 108 |
|
@@ -176,11 +177,14 @@ proc publish*(p: PackageInfo, o: Options) = |
176 | 177 | # https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth |
177 | 178 | display("Copying", "packages fork into: " & pkgsDir, priority = HighPriority) |
178 | 179 | doCmd("git init") |
| 180 | + # The repo will have 0 branches created at this point. So the |
| 181 | + # below command will always work. |
| 182 | + doCmd("git checkout -b " & defaultBranch) |
179 | 183 | doCmd("git pull https://github.com/" & auth.user & "/packages") |
180 | 184 | # Make sure to update the fork |
181 | 185 | display("Updating", "the fork", priority = HighPriority) |
182 | | - doCmd("git pull https://github.com/nim-lang/packages.git master") |
183 | | - doCmd("git push https://" & auth.token & "@github.com/" & auth.user & "/packages master") |
| 186 | + doCmd("git pull https://github.com/nim-lang/packages.git " & defaultBranch) |
| 187 | + doCmd("git push https://" & auth.token & "@github.com/" & auth.user & "/packages " & defaultBranch) |
184 | 188 |
|
185 | 189 | if not dirExists(pkgsDir): |
186 | 190 | raise newException(NimbleError, |
|
0 commit comments