switch to using GitHub library for PRs

unfortunately, this breaks PRs for single updates so removing that
feature advertisement for now.
This commit is contained in:
Ryan Mulligan 2020-04-14 21:54:59 -07:00
parent ed230936ac
commit d3690e0f69
4 changed files with 10 additions and 15 deletions

View File

@ -103,7 +103,6 @@ nixpkgs-update supports interactive, single package updates via the
# Flags
* `--pr`—uses Hub to submit a PR to GitHub.
* `--cve`—adds CVE vulnerability reporting to the PR message. On
first invocation with this option, a CVE database is
built. Subsequent invocations will be much faster.

View File

@ -140,7 +140,7 @@ main = do
setupNixpkgs token
P.setEnv "PAGER" "" True
P.setEnv "GITHUB_TOKEN" (T.unpack token) True
result <- updatePackage (Options pr False token cve cachix nixpkgsReview False) update
result <- updatePackage (Options False False token cve cachix nixpkgsReview False) update
case result of
Left e -> T.putStrLn e
Right () -> T.putStrLn "Done."

View File

@ -19,7 +19,6 @@ where
import Control.Applicative (some)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as T
import qualified Data.Vector as V
import GitHub
@ -29,8 +28,6 @@ import qualified Text.Regex.Applicative.Text as RE
import Text.Regex.Applicative.Text ((=~))
import Utils (UpdateEnv (..), Version)
import qualified Utils as U
import System.IO.Temp (withSystemTempFile)
import System.IO (hFlush)
default (T.Text)
@ -45,15 +42,13 @@ releaseUrl env url = do
urlParts <- parseURL url
gReleaseUrl (authFrom env) urlParts
pr :: MonadIO m => Text -> Text -> m ()
pr base msg = do
liftIO $ withSystemTempFile
(T.unpack $ base <> "-prmsg")
(\fp handle -> do
T.hPutStr handle msg
hFlush handle
runProcess_ $
proc "hub" ["pull-request", "-b", T.unpack base, "-F", fp])
pr :: MonadIO m => UpdateEnv -> Text -> Text -> Text -> Text -> ExceptT Text m Text
pr env title body prHead base = do
ExceptT $
bimap (T.pack . show) (getUrl . pullRequestUrl)
<$> (liftIO $ (github (authFrom env)
(createPullRequestR (N "nixos") (N "nixpkgs")
(CreatePullRequest title body prHead base))))
data URLParts
= URLParts

View File

@ -347,7 +347,8 @@ publishPackage log updateEnv oldSrcUrl newSrcUrl attrPath result opDiff msgs = d
if (isNothing opDiff || numPackageRebuilds (fromJust opDiff) < 100)
then "master"
else "staging"
lift $ GH.pr base prMsg
pullRequestUrl <- GH.pr updateEnv (prTitle updateEnv attrPath) prMsg ("r-ryantm:" <> (branchName updateEnv)) base
liftIO $ log pullRequestUrl
else liftIO $ T.putStrLn prMsg
commitMessage :: UpdateEnv -> Text -> Text