Hello community, here is the log from the commit of package ghc-distribution-opensuse for openSUSE:Factory checked in at 2018-07-28 12:42:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-distribution-opensuse (Old) and /work/SRC/openSUSE:Factory/.ghc-distribution-opensuse.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-distribution-opensuse" Sat Jul 28 12:42:34 2018 rev:2 rq:625306 version:1.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-distribution-opensuse/ghc-distribution-opensuse.changes 2018-07-25 16:08:05.237325990 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-distribution-opensuse.new/ghc-distribution-opensuse.changes 2018-07-28 12:42:34.812676991 +0200 @@ -1,0 +2,6 @@ +Mon Jul 23 16:19:08 UTC 2018 - psim...@suse.com + +- Update distribution-opensuse to version 1.1.1. + Upstream does not provide a change log. + +------------------------------------------------------------------- Old: ---- distribution-opensuse-1.0.0.tar.gz New: ---- distribution-opensuse-1.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-distribution-opensuse.spec ++++++ --- /var/tmp/diff_new_pack.uXErFP/_old 2018-07-28 12:42:35.216677767 +0200 +++ /var/tmp/diff_new_pack.uXErFP/_new 2018-07-28 12:42:35.216677767 +0200 @@ -18,7 +18,7 @@ %global pkg_name distribution-opensuse Name: ghc-%{pkg_name} -Version: 1.0.0 +Version: 1.1.1 Release: 0 Summary: Types, functions, and tools to manipulate the openSUSE distribution License: BSD-3-Clause @@ -44,9 +44,12 @@ BuildRequires: ghc-text-devel BuildRequires: ghc-time-devel BuildRequires: ghc-turtle-devel +BuildRequires: pandoc %description -Types, functions, and tools to manipulate the openSUSE distribution. +This library is a loose collection of types, functions, and tools that users +and developers of the <https://opensuse.org/ openSUSE Linux distribution> might +find useful. %package devel Summary: Haskell %{pkg_name} library development files @@ -65,10 +68,12 @@ %build %ghc_lib_build +pandoc -s -t man -o guess-changelog.1 guess-changelog.md %install %ghc_lib_install %ghc_fix_rpath %{pkg_name}-%{version} +install -D -m 644 guess-changelog.1 %{buildroot}%{_mandir}/man1/guess-changelog.1 %post devel %ghc_pkg_recache @@ -79,8 +84,8 @@ %files -f %{name}.files %license LICENSE %{_bindir}/guess-changelog +%{_mandir}/man1/guess-changelog.1%{?ext_man} %files devel -f %{name}-devel.files -%doc README.md %changelog ++++++ distribution-opensuse-1.0.0.tar.gz -> distribution-opensuse-1.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/LICENSE new/distribution-opensuse-1.1.1/LICENSE --- old/distribution-opensuse-1.0.0/LICENSE 2018-07-17 16:46:24.000000000 +0200 +++ new/distribution-opensuse-1.1.1/LICENSE 2018-07-23 17:55:33.000000000 +0200 @@ -1,4 +1,4 @@ -Copyright (c) 2018, Peter Simons +Copyright (c) 2018 Peter Simons of SUSE Linux GmbH. All rights reserved. @@ -13,9 +13,10 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Peter Simons nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. + * Neither the name of Peter Simons, SUSE Linux GmbH, nor the names + of other contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/README.md new/distribution-opensuse-1.1.1/README.md --- old/distribution-opensuse-1.0.0/README.md 2018-07-17 16:46:24.000000000 +0200 +++ new/distribution-opensuse-1.1.1/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,9 +0,0 @@ -distribution-opensuse -===================== - -[![hackage release](https://img.shields.io/hackage/v/distribution-opensuse.svg?label=hackage)](http://hackage.haskell.org/package/distribution-opensuse) -[![stackage LTS package](http://stackage.org/package/distribution-opensuse/badge/lts)](http://stackage.org/lts/package/distribution-opensuse) -[![stackage Nightly package](http://stackage.org/package/distribution-opensuse/badge/nightly)](http://stackage.org/nightly/package/distribution-opensuse) -[![travis build status](https://img.shields.io/travis/peti/distribution-opensuse/master.svg?label=travis+build)](https://travis-ci.org/peti/distribution-opensuse) - -Types, functions, and tools to manipulate the openSUSE distribution. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/distribution-opensuse.cabal new/distribution-opensuse-1.1.1/distribution-opensuse.cabal --- old/distribution-opensuse-1.0.0/distribution-opensuse.cabal 2018-07-17 16:46:24.000000000 +0200 +++ new/distribution-opensuse-1.1.1/distribution-opensuse.cabal 2018-07-23 17:55:33.000000000 +0200 @@ -1,7 +1,9 @@ name: distribution-opensuse -version: 1.0.0 +version: 1.1.1 synopsis: Types, functions, and tools to manipulate the openSUSE distribution -description: Types, functions, and tools to manipulate the openSUSE distribution. +description: This library is a loose collection of types, functions, and tools that + users and developers of the + <https://opensuse.org/ openSUSE Linux distribution> might find useful. license: BSD3 license-file: LICENSE author: Peter Simons @@ -9,8 +11,9 @@ tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.3 category: Distribution homepage: https://github.com/peti/distribution-opensuse/ +bug-reports: https://github.com/peti/distribution-opensuse/issues build-type: Simple -extra-source-files: README.md +extra-source-files: guess-changelog.md tests/run-tests tests/guess-changelog/*.test cabal-version: >= 1.10 @@ -25,6 +28,7 @@ OpenSuse.Prelude.Parser OpenSuse.Prelude.PrettyPrinting OpenSuse.Prelude.PrettyPrinting.Orphans + OpenSuse.StripSpace OpenSuse.Types.ChangeLog OpenSuse.Types.EMailAddress OpenSuse.Types.Issue @@ -61,4 +65,14 @@ default-language: Haskell2010 default-extensions: MonadFailDesugaring ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates + -Wredundant-constraints -threaded + +test-suite test-strip-space + type: exitcode-stdio-1.0 + main-is: test-strip-space.hs + hs-source-dirs: tests + build-depends: base, distribution-opensuse + default-language: Haskell2010 + default-extensions: MonadFailDesugaring + ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates -Wredundant-constraints -threaded diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/guess-changelog.hs new/distribution-opensuse-1.1.1/guess-changelog.hs --- old/distribution-opensuse-1.0.0/guess-changelog.hs 2018-07-17 16:46:24.000000000 +0200 +++ new/distribution-opensuse-1.1.1/guess-changelog.hs 2018-07-23 17:55:33.000000000 +0200 @@ -20,17 +20,16 @@ main :: IO () main = do - (oldDir,newDir) <- options "Guess the change log entry between two version of a package." parser + (oldDir,newDir) <- options "Guess the change log entry between two versions of a package." parser result <- guessChangeLog oldDir newDir case result of - Right txt -> Text.putStrLn txt - Left desc -> case desc of - NoChangeLogFiles -> eprintf "no change log files found\n" - UndocumentedUpdate p -> eprintf ("file "%fp%" has not changed between releases\n") p - NoCommonChangeLogFiles l r -> eprintf ("both directories have no files in common: "%fps%" vs. "%fps%"\n") l r - MoreThanOneChangeLogFile p -> eprintf ("too many changelog files: "%fps%"\n") p - UnmodifiedTopIsTooLarge p n -> eprintf (fp%" has more than 10 unmodified lines at top: "%d%"\n") p n - NotJustTopAdditions p -> eprintf (fp%" has more edits than just adding at the top\n") p + GuessedChangeLog _ txt -> Text.putStr txt + NoChangeLogFiles -> eprintf "no change log files found\n" + UndocumentedUpdate p -> eprintf ("file "%fp%" has not changed between releases\n") p + NoCommonChangeLogFiles l r -> eprintf ("both directories have no files in common: "%fps%" vs. "%fps%"\n") l r + MoreThanOneChangeLogFile p -> eprintf ("too many changelog files: "%fps%"\n") p + UnmodifiedTopIsTooLarge p n -> eprintf (fp%" has more than 10 unmodified lines at top: "%d%"\n") p n + NotJustTopAdditions p -> eprintf (fp%" has more edits than just adding at the top\n") p -- * Utility Functions diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/guess-changelog.md new/distribution-opensuse-1.1.1/guess-changelog.md --- old/distribution-opensuse-1.0.0/guess-changelog.md 1970-01-01 01:00:00.000000000 +0100 +++ new/distribution-opensuse-1.1.1/guess-changelog.md 2018-07-23 17:55:33.000000000 +0200 @@ -0,0 +1,77 @@ +% GUESS-CHANGELOG(1) Guess change descriptions between releases + +# NAME + +guess-changelog -- Extract additions to change log file between releases + +# SYNOPSIS + +**guess-changelog** OLD-DIR NEW-DIR + +# DESCRIPTION + +Many free software authors include a (manually maintained) change log file in +their release tarballs that describes important changes from one version to the +next, and it's good practice for distribution packagers to include that +information in meta sections of their packaging efforts so that the package +managing software can easily display it to users during updates, etc. In the +rpm(8) world, this is usually accomplished by adding a `pkg-name.changes` file +next to the `pkg-name.spec` file that mentions relevant bits of the upstream +change log. + +Now, this tools makes tries to extract the necessary information from upstream +releases automatically. Given to release tarballs `foo-X.tar.gz` and +`foo-Y.tar.gz`, just extract those tarballs and run `guess-changelog` with the +appropriate directories as arguments: + + $ guess-changelog foo-X foo-Y + +If `guess-changelog` can determine the part of the change log that was added +between the two releases, it will write the text to standard output. On some +occasions, however, `guess-changelog` will fail: + +* Neither release contains a change log file. + +* A change log file exists, but it's identical in both releases. In other + words, upstream probably forgot to document the release. + +* Both releases contain a set of files that look like they might be a change + log, but their intersection is empty! This happens, for example, when + upstream has renamed the file. + +* Multiple change log files exists in both directories. Now, it would probably + work out okay if we'd just look at the diffs of both of them, respectively, + but it felt like a good idea to err on the side of caution. This case is rare + anyways. + +* `guess-changelog` accepts up to 10 lines of unmodified text at the top of the + upstream change log file because some people like to have a short + introduction text there etc. If that header becomes too large, however, an + error is returned because we expect upstream to add text at the *top*, not in + the middle of the file. + +* Upstream has edited the file in some non-trivial way other than just adding + at the top. Sometimes people re-format old entries or rewrite URLs or fix + typos, and in such a case it feels to risky to trust the diff. + +# RETURN VALUES + +`guess-changelog` returns a non-zero exit code only if some kind of +system-level error ocurred, such as a permission error while trying to access +the given directories. In all other cases, the tool exists with 0. + +If a change log entry was detected successfully, it will be written to standard +output. In no change log entry could be detected, the tool writes a brief +explanation of the issue to the standard error stream, but it won't write to +standard output. + +# AUTHOR + +ShellCheck is written and maintained by Peter Simons. Please report any bugs +you may find at <https://github.com/peti/distribution-opensuse/>. + +# COPYRIGHT + +Copyright 2018 by Peter Simons of SUSE Linux GmbH. + +Licensed under the terms of the [BSD-3-Clause license](https://opensource.org/licenses/BSD-3-Clause). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/src/OpenSuse/GuessChangeLog.hs new/distribution-opensuse-1.1.1/src/OpenSuse/GuessChangeLog.hs --- old/distribution-opensuse-1.0.0/src/OpenSuse/GuessChangeLog.hs 2018-07-17 16:46:24.000000000 +0200 +++ new/distribution-opensuse-1.1.1/src/OpenSuse/GuessChangeLog.hs 2018-07-23 17:55:33.000000000 +0200 @@ -1,8 +1,9 @@ -{-# LANGUAGE ApplicativeDo #-} {-# LANGUAGE OverloadedStrings #-} module OpenSuse.GuessChangeLog ( guessChangeLog, GuessedChangeLog(..) ) where +import OpenSuse.StripSpace + import qualified Control.Foldl as Fold import Control.Monad.Except import Data.Algorithm.Diff @@ -10,10 +11,32 @@ import qualified Data.Set as Set import qualified Data.Text as Text import Prelude hiding ( FilePath ) -import Turtle hiding ( l, x ) +import Turtle hiding ( l, x, stderr, stdout ) + +-- | Automatically guess the differences between to releases of a package by +-- looking at the change log file provided by upstream. The function as +-- arguments the paths of two directories that contain the extracted release +-- tarballs. The first arguments ought to point to the older release, the +-- second paths ought to point to the updated version. +-- +-- The function uses the following algorithm to detect the relevant changes: +-- +-- 1. Scan both directories for files that look like they might be change +-- logs. +-- +-- 2. If both directories contain the same candidate file, e.g. @ChangeLog@, +-- then use that. +-- +-- 3. Compute the differences between the change log files and check that all +-- modifications are additions at the top of the file. +-- +-- 4. Return those additions as 'Text'. -guessChangeLog :: FilePath -> FilePath -> IO (Either GuessedChangeLog Text) -guessChangeLog oldDir newDir = runExceptT $ do +guessChangeLog :: FilePath -> FilePath -> IO GuessedChangeLog +guessChangeLog oldDir = fmap (either id id) . guessChangeLog' oldDir + +guessChangeLog' :: FilePath -> FilePath -> IO (Either GuessedChangeLog GuessedChangeLog) +guessChangeLog' oldDir newDir = runExceptT $ do oldCLF <- Set.fromList <$> listShell (findChangeLogFiles oldDir) newCLF <- Set.fromList <$> listShell (findChangeLogFiles newDir) when (all null [oldCLF,newCLF]) (throwError NoChangeLogFiles) @@ -22,11 +45,8 @@ [] -> throwError (NoCommonChangeLogFiles oldCLF newCLF) [clf] -> return clf _ -> throwError (MoreThanOneChangeLogFile clf') - (oec,old) <- shellStrict (format ("git stripspace < "%fp) (oldDir </> clf)) empty - (nec,new) <- shellStrict (format ("git stripspace < "%fp) (newDir </> clf)) empty - unless (all (== ExitSuccess) [oec,nec]) $ - -- TODO: Throw a proper exception here, or even don't even rely on git-stripspace. - die (format ("git stripspace failed with "%w%"\n") oec) + old <- stripSpace <$> liftIO (readTextFile (oldDir </> clf)) + new <- stripSpace <$> liftIO (readTextFile (newDir </> clf)) let changes = cleanupEmptyLines (getDiff (Text.lines old) (Text.lines new)) (top,diff) = span inBoth changes (add,foot) = span inSecond diff @@ -34,14 +54,43 @@ when (all inBoth changes) (throwError (UndocumentedUpdate clf)) unless (length top < 10) (throwError (UnmodifiedTopIsTooLarge clf (fromIntegral (length top)))) unless topAddOnly (throwError (NotJustTopAdditions clf)) - return (Text.strip (Text.unlines (map unDiff add))) + return (GuessedChangeLog clf (stripSpace (Text.unlines (map unDiff add)))) + +-- -data GuessedChangeLog = NoChangeLogFiles - | UndocumentedUpdate FilePath - | NoCommonChangeLogFiles (Set FilePath) (Set FilePath) - | MoreThanOneChangeLogFile (Set FilePath) - | UnmodifiedTopIsTooLarge FilePath Word - | NotJustTopAdditions FilePath +data GuessedChangeLog + = GuessedChangeLog FilePath Text + -- ^ Both releases contained the given change log file, and these files + -- differed so that the given text was added at the top of the new one. + -- The text undergoes some amount of cleanup, i.e. we'll trim leading + -- empty lines at the top, trailing whitespace, and trailing empty + -- lines at the end. + | NoChangeLogFiles + -- ^ Neither release contains a change log file. + | UndocumentedUpdate FilePath + -- ^ A change log file exists (and its name is returned), but it's + -- identical in both releases. In other words, upstream probably forgot + -- to document the release. + | NoCommonChangeLogFiles (Set FilePath) (Set FilePath) + -- ^ Both releases contain a set of files that look like they might be + -- a change log, but their intersection is empty! This happens, for + -- example, when upstream has renamed the file. + | MoreThanOneChangeLogFile (Set FilePath) + -- ^ Multiple change log files exists in both directories. Now, it + -- would probably work out okay if we'd just look at the diffs of both + -- of them, respectively, but it felt like a good idea to err on the + -- side of caution. This case is rare anyways. + | UnmodifiedTopIsTooLarge FilePath Word + -- ^ 'guessChangelog' accepts up to 10 lines of unmodified text at the + -- top of the upstream change log file because some people like to have + -- a short introduction text there etc. If that header becomes too + -- large, however, then we return this error because we expect upstream + -- to add text at the top, not in the middle of the file. + | NotJustTopAdditions FilePath + -- ^ This happens when upstream edits the file in ways other than just + -- adding at the top. Sometimes people re-format old entries or rewrite + -- URLs or fix typos, and in such a case it feels to risky to trust the + -- diff. deriving (Show) cleanupEmptyLines :: [Diff Text] -> [Diff Text] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/src/OpenSuse/StripSpace.hs new/distribution-opensuse-1.1.1/src/OpenSuse/StripSpace.hs --- old/distribution-opensuse-1.0.0/src/OpenSuse/StripSpace.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/distribution-opensuse-1.1.1/src/OpenSuse/StripSpace.hs 2018-07-23 17:55:33.000000000 +0200 @@ -0,0 +1,42 @@ +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE OverloadedStrings #-} + +module OpenSuse.StripSpace ( stripSpace ) where + +import OpenSuse.Prelude + +import qualified Data.Text as Text + +-- | A (quite possibly inefficient) re-implementation of @git stripspace@. This +-- function normalizes a 'Text' buffer to conform to the following rules: +-- +-- * All trailing white space is stripped. +-- +-- * Empty lines at the beginning or at the end of the buffer are stripped. +-- +-- * Consecutive empty lines between paragraphs are collapsed into one. +-- +-- * @\\r\\n@ line endings are normalized into @\\n@. +-- +-- * If the buffer is not empty, then its last line is terminated by @\\n@. +-- +-- * If the buffer is empty (i.e. it contains only white space), then it comes +-- out as the empty string. + +stripSpace :: Text -> Text +stripSpace = Text.unlines + . normalizeEndOfText + . normalizeEmptyLines Skip + . map Text.stripEnd + . Text.lines + +data Mode = Skip | Keep + +normalizeEmptyLines :: Mode -> [Text] -> [Text] +normalizeEmptyLines _ [] = [] +normalizeEmptyLines Skip ("":ls) = normalizeEmptyLines Skip ls +normalizeEmptyLines Keep ("":ls) = "" : normalizeEmptyLines Skip ls +normalizeEmptyLines _ (l:ls) = l : normalizeEmptyLines Keep ls + +normalizeEndOfText :: [Text] -> [Text] +normalizeEndOfText = reverse . dropWhile Text.null . reverse diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/distribution-opensuse-1.0.0/tests/test-strip-space.hs new/distribution-opensuse-1.1.1/tests/test-strip-space.hs --- old/distribution-opensuse-1.0.0/tests/test-strip-space.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/distribution-opensuse-1.1.1/tests/test-strip-space.hs 2018-07-23 17:55:33.000000000 +0200 @@ -0,0 +1,33 @@ +{-# LANGUAGE NoImplicitPrelude #-} + +module Main where + +import OpenSuse.Prelude +import OpenSuse.StripSpace + +{-# INLINE (~~>) #-} +(~~>) :: String -> String -> (Text, Text) +(~~>) input result = (packText input, packText result) + +testCases :: [(Text, Text)] +testCases = + [ "para1\n\r\n\n para2 \n\r\r\n\n" ~~> "para1\n\n para2\n" + , "line1\nline2\r\nline3\n" ~~> "line1\nline2\nline3\n" + , "line1\nline2\n" ~~> "line1\nline2\n" + , "line1" ~~> "line1\n" + , "line 1 \r and still line 1" ~~> "line 1 \r and still line 1\n" + , "" ~~> "" + , "\n" ~~> "" + , " \n" ~~> "" + , " \n \n\n \n " ~~> "" + ] + +main :: IO () +main = + forM_ testCases $ \(inp,expct) -> do + let r = stripSpace inp + unless (r == expct) $ + fail (unwords [ "stripped version of", show inp + , "is", show r + , "not the expected", show expct + ])