Skip to content

Commit

Permalink
Merge pull request #1036 from ire4ever1190/implement-1016
Browse files Browse the repository at this point in the history
Add info into body of PR when publishing
  • Loading branch information
Araq authored Nov 7, 2022
2 parents 1df4a0d + a358054 commit 73a9796
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/nimblepkg/publish.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import system except TResult
import httpclient, strutils, json, os, browsers, times, uri
import common, tools, cli, config, options, packageinfotypes
import strformat
{.warning[UnusedImport]: off.}
from net import SslCVerifyMode, newContext

Expand Down Expand Up @@ -98,11 +99,15 @@ proc createFork(a: Auth) =
raise nimbleError("Unable to create fork. Access token" &
" might not have enough permissions.")

proc createPullRequest(a: Auth, packageName, branch: string): string =
proc createPullRequest(a: Auth, pkg: PackageInfo, url, branch: string): string =
display("Info", "Creating PR", priority = HighPriority)
var body = a.http.postContent(ReposUrl & "nim-lang/packages/pulls",
body="""{"title": "Add package $1", "head": "$2:$3",
"base": "$4"}""" % [packageName, a.user, branch, defaultBranch])
let payload = %* {
"title": &"Add package {pkg.basicInfo.name}",
"head": &"{a.user}:{branch}",
"base": defaultBranch,
"body": &"{pkg.description}\n\n{url}"
}
var body = a.http.postContent(ReposUrl & "nim-lang/packages/pulls", $payload)
var pr = parseJson(body)
return pr{"html_url"}.getStr()

Expand Down Expand Up @@ -240,5 +245,5 @@ proc publish*(p: PackageInfo, o: Options) =
doCmd("git commit packages.json -m \"Added package " & p.basicInfo.name & "\"")
display("Pushing", "to remote of fork.", priority = HighPriority)
doCmd("git push https://" & auth.token & "@github.com/" & auth.user & "/packages " & branchName)
let prUrl = createPullRequest(auth, p.basicInfo.name, branchName)
let prUrl = createPullRequest(auth, p, url, branchName)
display("Success:", "Pull request successful, check at " & prUrl , Success, HighPriority)

0 comments on commit 73a9796

Please sign in to comment.