mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-28 23:22:00 +03:00
parent
7e6f43d696
commit
236481fef1
29
src/GH.hs
29
src/GH.hs
@ -201,23 +201,34 @@ authFromToken = GH.OAuth . T.encodeUtf8
|
||||
authFrom :: UpdateEnv -> GH.Auth
|
||||
authFrom = authFromToken . U.githubToken . options
|
||||
|
||||
checkExistingUpdatePR :: MonadIO m => UpdateEnv -> Text -> ExceptT Text m ()
|
||||
checkExistingUpdatePR env attrPath = do
|
||||
checkExistingUpdatePR :: MonadIO m => UpdateEnv -> Text -> Text -> ExceptT Text m ()
|
||||
checkExistingUpdatePR env attrPath srcUrl = do
|
||||
searchResult <-
|
||||
ExceptT $
|
||||
liftIO $
|
||||
GH.github (authFrom env) (GH.searchIssuesR search)
|
||||
& fmap (first (T.pack . show))
|
||||
if T.length (openPRReport searchResult) == 0
|
||||
then return ()
|
||||
else
|
||||
throwE
|
||||
( "There might already be an open PR for this update:\n"
|
||||
<> openPRReport searchResult
|
||||
)
|
||||
when (T.length (openPRReport searchResult) /= 0)
|
||||
(throwE
|
||||
( "There might already be an open PR for this update:\n"
|
||||
<> openPRReport searchResult))
|
||||
|
||||
srcUrlSearchResult <-
|
||||
ExceptT $
|
||||
liftIO $
|
||||
GH.github (authFrom env) (GH.searchIssuesR srcUrlSearch)
|
||||
& fmap (first (T.pack . show))
|
||||
|
||||
when (T.length (openPRReport srcUrlSearchResult) /= 0)
|
||||
(throwE
|
||||
( "There might already be an open PR for this update:\n"
|
||||
<> openPRReport searchResult))
|
||||
|
||||
return ()
|
||||
where
|
||||
title = U.prTitle env attrPath
|
||||
search = [interpolate|repo:nixos/nixpkgs $title |]
|
||||
srcUrlSearch = [interpolate|new src url: $srcUrl |]
|
||||
openPRReport searchResult =
|
||||
GH.searchResultResults searchResult
|
||||
& V.filter (GH.issueClosedAt >>> isNothing)
|
||||
|
@ -10,6 +10,7 @@ module Git
|
||||
deleteBranchesEverywhere,
|
||||
delete1,
|
||||
diff,
|
||||
diffNameOnly,
|
||||
fetch,
|
||||
fetchIfStale,
|
||||
headRev,
|
||||
@ -112,6 +113,9 @@ cleanup bName = do
|
||||
diff :: MonadIO m => Text -> ExceptT Text m Text
|
||||
diff branch = readProcessInterleavedNoIndexIssue_ $ procGit ["diff", T.unpack branch]
|
||||
|
||||
diffNameOnly :: MonadIO m => Text -> ExceptT Text m Text
|
||||
diffNameOnly branch = readProcessInterleavedNoIndexIssue_ $ procGit ["diff", "--name-only", T.unpack branch]
|
||||
|
||||
staleFetchHead :: MonadIO m => m Bool
|
||||
staleFetchHead =
|
||||
liftIO $ do
|
||||
|
10
src/Nix.hs
10
src/Nix.hs
@ -19,6 +19,7 @@ module Nix
|
||||
getHomepageET,
|
||||
getIsBroken,
|
||||
getMaintainers,
|
||||
getMetaPosition,
|
||||
getOldHash,
|
||||
getOutpaths,
|
||||
getPatches,
|
||||
@ -214,6 +215,15 @@ getChangelog attrPath =
|
||||
<> ".meta.changelog or \"\")"
|
||||
)
|
||||
|
||||
getMetaPosition :: MonadIO m => Text -> ExceptT Text m Text
|
||||
getMetaPosition attrPath =
|
||||
nixEvalET
|
||||
(EvalOptions NoRaw (Env []))
|
||||
( "(let pkgs = import ./. {}; in pkgs."
|
||||
<> attrPath
|
||||
<> ".meta.position or \"\")"
|
||||
)
|
||||
|
||||
getDescription :: MonadIO m => Text -> ExceptT Text m Text
|
||||
getDescription attrPath =
|
||||
nixEvalET
|
||||
|
@ -247,8 +247,9 @@ checkExistingUpdate ::
|
||||
UpdateEnv ->
|
||||
Maybe Text ->
|
||||
Text ->
|
||||
Text ->
|
||||
ExceptT Text IO ()
|
||||
checkExistingUpdate log updateEnv existingCommitMsg attrPath = do
|
||||
checkExistingUpdate log updateEnv existingCommitMsg srcUrl attrPath = do
|
||||
case existingCommitMsg of
|
||||
Nothing -> lift $ log "No auto update branch exists"
|
||||
Just msg -> do
|
||||
@ -263,7 +264,7 @@ checkExistingUpdate log updateEnv existingCommitMsg attrPath = do
|
||||
-- Note that this check looks for PRs with the same old and new
|
||||
-- version numbers, so it won't stop us from updating an existing PR
|
||||
-- if this run updates the package to a newer version.
|
||||
GH.checkExistingUpdatePR updateEnv attrPath
|
||||
GH.checkExistingUpdatePR updateEnv attrPath srcUrl
|
||||
|
||||
updateAttrPath ::
|
||||
(Text -> IO ()) ->
|
||||
@ -277,7 +278,7 @@ updateAttrPath log mergeBase updateEnv@UpdateEnv {..} attrPath = do
|
||||
|
||||
successOrFailure <- runExceptT $ do
|
||||
hasUpdateScript <- Nix.hasUpdateScript attrPath
|
||||
|
||||
oldSrcUrl <- Nix.getSrcUrl attrPath <|> pure ""
|
||||
existingCommitMsg <- fmap getAlt . execWriterT $
|
||||
whenBatch updateEnv do
|
||||
Skiplist.attrPath attrPath
|
||||
@ -286,7 +287,7 @@ updateAttrPath log mergeBase updateEnv@UpdateEnv {..} attrPath = do
|
||||
mbLastCommitMsg <- lift $ Git.findAutoUpdateBranchMessage packageName
|
||||
tell $ Alt mbLastCommitMsg
|
||||
unless hasUpdateScript do
|
||||
lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath
|
||||
lift $ checkExistingUpdate log updateEnv mbLastCommitMsg attrPath oldSrcUrl
|
||||
|
||||
unless hasUpdateScript do
|
||||
Nix.assertNewerVersion updateEnv
|
||||
@ -310,7 +311,6 @@ updateAttrPath log mergeBase updateEnv@UpdateEnv {..} attrPath = do
|
||||
-- Get the original values for diffing purposes
|
||||
derivationContents <- liftIO $ T.readFile $ T.unpack derivationFile
|
||||
oldHash <- Nix.getOldHash attrPath <|> pure ""
|
||||
oldSrcUrl <- Nix.getSrcUrl attrPath <|> pure ""
|
||||
oldRev <- Nix.getAttr Nix.Raw "rev" attrPath <|> pure ""
|
||||
oldVerMay <- rightMay `fmapRT` (lift $ runExceptT $ Nix.getAttr Nix.Raw "version" attrPath)
|
||||
|
||||
@ -379,17 +379,18 @@ updateAttrPath log mergeBase updateEnv@UpdateEnv {..} attrPath = do
|
||||
assertNotUpdatedOn updateEnv' derivationFile "master"
|
||||
assertNotUpdatedOn updateEnv' derivationFile "staging"
|
||||
assertNotUpdatedOn updateEnv' derivationFile "staging-next"
|
||||
|
||||
whenBatch updateEnv do
|
||||
when pr do
|
||||
when hasUpdateScript do
|
||||
checkExistingUpdate log updateEnv' existingCommitMsg attrPath
|
||||
checkExistingUpdate log updateEnv' existingCommitMsg attrPath newSrcUrl
|
||||
|
||||
Nix.build attrPath
|
||||
|
||||
--
|
||||
-- Publish the result
|
||||
lift . log $ "Successfully finished processing"
|
||||
result <- Nix.resultLink
|
||||
result <- Nix.resultLink
|
||||
let opReport =
|
||||
if isJust skipOutpathBase
|
||||
then "Outpath calculations were skipped for this package; total number of rebuilds unknown."
|
||||
@ -455,6 +456,7 @@ publishPackage log updateEnv oldSrcUrl newSrcUrl attrPath result opReport prBase
|
||||
metaDescription
|
||||
metaHomepage
|
||||
metaChangelog
|
||||
newSrcUrl
|
||||
rewriteMsgs
|
||||
releaseUrl
|
||||
compareUrl
|
||||
@ -494,6 +496,7 @@ prMessage ::
|
||||
Text ->
|
||||
Text ->
|
||||
Text ->
|
||||
Text ->
|
||||
[Text] ->
|
||||
Text ->
|
||||
Text ->
|
||||
@ -507,7 +510,7 @@ prMessage ::
|
||||
Text ->
|
||||
Text ->
|
||||
Text
|
||||
prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteMsgs releaseUrl compareUrl resultCheckReport commitRev attrPath maintainers resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg =
|
||||
prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog newSrcUrl rewriteMsgs releaseUrl compareUrl resultCheckReport commitRev attrPath maintainers resultPath opReport cveRep cachixTestInstructions nixpkgsReviewMsg =
|
||||
-- Some components of the PR description are pre-generated prior to calling
|
||||
-- because they require IO, but in general try to put as much as possible for
|
||||
-- the formatting into the pure function so that we can control the body
|
||||
@ -538,6 +541,8 @@ prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteM
|
||||
if compareUrl == T.empty
|
||||
then ""
|
||||
else "- [Compare changes on GitHub](" <> compareUrl <> ")"
|
||||
-- Needed for search of existing PRs
|
||||
newSrcUrlLine = "- new src url: " <> newSrcUrl
|
||||
nixpkgsReviewSection =
|
||||
if nixpkgsReviewMsg == T.empty
|
||||
then "NixPkgs review skipped"
|
||||
@ -571,6 +576,8 @@ prMessage updateEnv isBroken metaDescription metaHomepage metaChangelog rewriteM
|
||||
|
||||
###### To inspect upstream changes
|
||||
|
||||
$newSrcUrlLine
|
||||
|
||||
$releaseUrlMessage
|
||||
|
||||
$compareUrlMessage
|
||||
|
Loading…
Reference in New Issue
Block a user