]> git.pld-linux.org Git - projects/git-slug.git/commitdiff
try to expand %_topdir before defaulting to ~/rpm/packages
authorJan Palus <jpalus@fastmail.com>
Fri, 1 Oct 2021 22:30:08 +0000 (00:30 +0200)
committerJan Palus <jpalus@fastmail.com>
Fri, 1 Oct 2021 22:30:08 +0000 (00:30 +0200)
slug.py

diff --git a/slug.py b/slug.py
index 17a67e71b6ff62e026585e8e86fdf0ce55dc56ec..da4e575ffada8b27f810f355c17f858487895c52 100755 (executable)
--- a/slug.py
+++ b/slug.py
@@ -222,9 +222,17 @@ def list_packages(options):
     for package in sorted(refs.heads):
         print(package)
 
+def default_packagesdir():
+    try:
+        import rpm
+        return rpm.expandMacro('%_topdir')
+    except:
+        return os.path.expanduser('~/rpm/packages')
+
+
 common_options = argparse.ArgumentParser(add_help=False)
 common_options.add_argument('-d', '--packagesdir', help='local directory with git repositories',
-    default=os.path.expanduser('~/rpm/packages'))
+    default=default_packagesdir())
 
 common_fetchoptions = argparse.ArgumentParser(add_help=False, parents=[common_options])
 common_fetchoptions.add_argument('-j', '--jobs', help='number of threads to use', default=cpu_count(), type=int)
This page took 0.249851 seconds and 4 git commands to generate.