git-gpush 2.0.0.0 → 2.0.1.0
raw patch · 2 files changed
+22/−8 lines, 2 filesdep +gitlib-cmdlinedep −gitlib-libgit2
Dependencies added: gitlib-cmdline
Dependencies removed: gitlib-libgit2
Files
- Main.hs +19/−6
- git-gpush.cabal +3/−2
Main.hs view
@@ -26,11 +26,23 @@ import qualified Data.Text.Lazy as TL hiding (tails) #endif import Git hiding (Options)-import Git.Libgit2 (lgFactory, withLibGitDo)+#if USE_LIBGIT2+import qualified Git.Libgit2 as Lg+#else+import qualified Git.CmdLine as Cli+#endif import Options.Applicative import Prelude hiding (FilePath, null) import Shelly +#if USE_LIBGIT2+factory :: RepositoryFactory Lg.LgRepository IO Lg.Repository+factory = Lg.lgFactory+#else+factory :: RepositoryFactory Cli.CmdLineRepository IO Cli.Repository+factory = Cli.cliFactory+#endif+ toStrict :: TL.Text -> T.Text #if MIN_VERSION_shelly(1, 0, 0) toStrict = id@@ -74,7 +86,7 @@ git_ = run_ "git" main :: IO ()-main = withLibGitDo $ execParser opts >>= pushToGitHub+main = withBackendDo factory $ execParser opts >>= pushToGitHub where opts = info (helper <*> options) (fullDesc <> progDesc desc <> header hdr)@@ -83,8 +95,7 @@ pushToGitHub :: Options -> IO () pushToGitHub opts = do- gd <- fromText . TL.init- <$> sh opts (run "git" ["rev-parse", "--git-dir"])+ gd <- fromText . TL.init <$> sh opts (run "git" ["rev-parse", "--git-dir"]) remoteName <- case remote opts of Nothing -> sh opts $ getRemoteName gd@@ -94,7 +105,9 @@ head . TL.words . TL.init <$> sh opts (git [ "ls-remote", remoteName, "HEAD" ]) - withRepository lgFactory gd $ do+ sh opts $ git_ [ "fetch" ]++ withRepository factory gd $ do cref <- fromJust <$> resolveReference "HEAD" hc <- lookupCommit cref rcoid <- Tagged <$> parseOid (toStrict remoteHead)@@ -110,7 +123,7 @@ getRemoteName :: FilePath -> Sh Text getRemoteName gd = do- mref <- liftIO $ withRepository lgFactory gd $ lookupReference "HEAD"+ mref <- liftIO $ withRepository factory gd $ lookupReference "HEAD" case mref of Nothing -> error "Could not find HEAD" Just (RefObj _) ->
git-gpush.cabal view
@@ -1,5 +1,5 @@ Name: git-gpush-Version: 2.0.0.0+Version: 2.0.1.0 Synopsis: More intelligent push-to-GitHub utility. Description: More intelligent push-to-GitHub utility.@@ -24,7 +24,8 @@ , bytestring >= 0.9.2.1 , containers >= 0.4.2.1 , gitlib >= 2.0.0.0- , gitlib-libgit2 >= 2.0.0.0+ , gitlib-cmdline >= 2.0.1.0+ -- , gitlib-libgit2 >= 2.0.0.0 , hslogger >= 1.2 , old-locale >= 1.0.0.4 , optparse-applicative >= 0.5.2.1