mirror of
https://github.com/ryantm/nixpkgs-update.git
synced 2025-01-06 03:26:11 +03:00
add --atterpath flag to support exact attrpath update info
This commit is contained in:
parent
a0a53c2d76
commit
5ae5261c11
16
app/Main.hs
16
app/Main.hs
@ -26,7 +26,8 @@ data UpdateOptions = UpdateOptions
|
||||
{ pr :: Bool,
|
||||
cve :: Bool,
|
||||
nixpkgsReview :: Bool,
|
||||
outpaths :: Bool
|
||||
outpaths :: Bool,
|
||||
attrpathOpt :: Bool
|
||||
}
|
||||
|
||||
data Command
|
||||
@ -47,6 +48,7 @@ updateOptionsParser =
|
||||
<*> O.flag False True (O.long "cve" <> O.help "Make a CVE vulnerability report.")
|
||||
<*> O.flag False True (O.long "nixpkgs-review" <> O.help "Runs nixpkgs-review on update commit rev")
|
||||
<*> O.flag False True (O.long "outpaths" <> O.help "Calculate outpaths to determine the branch to target")
|
||||
<*> O.flag False True (O.long "attrpath" <> O.help "UPDATE_INFO uses the exact attrpath.")
|
||||
|
||||
updateParser :: O.Parser Command
|
||||
updateParser =
|
||||
@ -134,13 +136,13 @@ main = do
|
||||
DeleteDone delete -> do
|
||||
Git.setupNixpkgs token
|
||||
deleteDone delete token ghUser
|
||||
UpdateList UpdateOptions {pr, cve, nixpkgsReview, outpaths} -> do
|
||||
UpdateList UpdateOptions {pr, cve, nixpkgsReview, outpaths, attrpathOpt} -> do
|
||||
updates <- T.readFile "packages-to-update.txt"
|
||||
Git.setupNixpkgs token
|
||||
updateAll (Options pr True ghUser token cve nixpkgsReview outpaths) updates
|
||||
Update UpdateOptions {pr, cve, nixpkgsReview} update -> do
|
||||
updateAll (Options pr True ghUser token cve nixpkgsReview outpaths attrpathOpt) updates
|
||||
Update UpdateOptions {pr, cve, nixpkgsReview, attrpathOpt} update -> do
|
||||
Git.setupNixpkgs token
|
||||
result <- updatePackage (Options pr False ghUser token cve nixpkgsReview False) update
|
||||
result <- updatePackage (Options pr False ghUser token cve nixpkgsReview False attrpathOpt) update
|
||||
case result of
|
||||
Left e -> T.putStrLn e
|
||||
Right () -> T.putStrLn "Done."
|
||||
@ -158,10 +160,10 @@ main = do
|
||||
setupNixpkgs undefined
|
||||
report <-
|
||||
cveReport
|
||||
(UpdateEnv productID oldVersion newVersion Nothing (Options False False ghUser token False False False))
|
||||
(UpdateEnv productID oldVersion newVersion Nothing (Options False False ghUser token False False False False))
|
||||
T.putStrLn report
|
||||
SourceGithub -> do
|
||||
updates <- T.readFile "packages-to-update.txt"
|
||||
setupNixpkgs token
|
||||
sourceGithubAll (Options False False ghUser token False False False) updates
|
||||
sourceGithubAll (Options False False ghUser token False False False False) updates
|
||||
FetchRepology -> Repology.fetch
|
||||
|
@ -52,6 +52,7 @@ import Utils
|
||||
prTitle,
|
||||
whenBatch,
|
||||
)
|
||||
import qualified Utils as U
|
||||
import qualified Version
|
||||
import Prelude hiding (log)
|
||||
|
||||
@ -93,6 +94,7 @@ notifyOptions log o = do
|
||||
let outpaths = repr calculateOutpaths
|
||||
let cve = repr makeCVEReport
|
||||
let review = repr runNixpkgsReview
|
||||
let exactAttrPath = repr U.attrpath
|
||||
npDir <- tshow <$> Git.nixpkgsDir
|
||||
log $
|
||||
[interpolate|
|
||||
@ -104,6 +106,7 @@ notifyOptions log o = do
|
||||
CVE Security Report: $cve
|
||||
Run nixpkgs-review: $review
|
||||
Nixpkgs Dir: $npDir
|
||||
update info uses attrpath: $exactAttrPath
|
||||
----------------------------------|]
|
||||
|
||||
updateAll :: Options -> Text -> IO ()
|
||||
@ -206,7 +209,9 @@ updatePackageBatch log updateEnv@UpdateEnv {..} mergeBaseOutpathsContext =
|
||||
Git.cleanAndResetTo "master"
|
||||
|
||||
-- Filters: various cases where we shouldn't update the package
|
||||
attrPath <- Nix.lookupAttrPath updateEnv
|
||||
attrPath <- if attrpath options
|
||||
then return packageName
|
||||
else Nix.lookupAttrPath updateEnv
|
||||
hasUpdateScript <- Nix.hasUpdateScript attrPath
|
||||
|
||||
whenBatch updateEnv do
|
||||
|
@ -109,7 +109,8 @@ data Options = Options
|
||||
githubToken :: Text,
|
||||
makeCVEReport :: Bool,
|
||||
runNixpkgsReview :: Bool,
|
||||
calculateOutpaths :: Bool
|
||||
calculateOutpaths :: Bool,
|
||||
attrpath :: Bool
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
|
@ -23,7 +23,7 @@ spec = do
|
||||
it "quotes an unquoted meta.homepage URL" do
|
||||
nixQuotedHomepageBad <- T.readFile "test_data/quoted_homepage_bad.nix"
|
||||
nixQuotedHomepageGood <- T.readFile "test_data/quoted_homepage_good.nix"
|
||||
let options = Utils.Options False False "r-ryantm" "" False False False
|
||||
let options = Utils.Options False False "r-ryantm" "" False False False False
|
||||
let updateEnv = Utils.UpdateEnv "inadyn" "2.5" "2.6" Nothing options
|
||||
-- TODO test correct file is being read
|
||||
let rwArgs = Rewrite.Args updateEnv "inadyn" undefined undefined False
|
||||
|
@ -18,7 +18,7 @@ spec :: Spec
|
||||
spec = do
|
||||
describe "PR message" do
|
||||
-- Common mock options
|
||||
let options = Utils.Options False False "r-ryantm" "" False False False
|
||||
let options = Utils.Options False False "r-ryantm" "" False False False False
|
||||
let updateEnv = Utils.UpdateEnv "foobar" "1.0" "1.1" (Just "https://update-site.com") options
|
||||
let isBroken = False
|
||||
let metaDescription = "\"Foobar package description\""
|
||||
|
@ -13,7 +13,7 @@ spec = do
|
||||
describe "PR title" do
|
||||
-- This breaks IRC when it tries to link to newly opened pull requests
|
||||
it "should not include a trailing newline" do
|
||||
let options = Utils.Options False False "" "" False False False
|
||||
let options = Utils.Options False False "" "" False False False False
|
||||
let updateEnv = Utils.UpdateEnv "foobar" "1.0" "1.1" (Just "https://update-site.com") options
|
||||
let title = Utils.prTitle updateEnv "python37Packages.foobar"
|
||||
title `shouldBe` "python37Packages.foobar: 1.0 -> 1.1"
|
||||
|
Loading…
Reference in New Issue
Block a user