From 04b032998e8ec09c9283180e15e66eea55e47fcf Mon Sep 17 00:00:00 2001 From: Marko Saukko Date: Thu, 2 May 2013 13:39:44 +0000 Subject: [PATCH 1/3] Check that .git exists. Signed-off-by: Marko Saukko --- gp_mkpkg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gp_mkpkg b/gp_mkpkg index 495dbe0..b481b89 100755 --- a/gp_mkpkg +++ b/gp_mkpkg @@ -314,6 +314,14 @@ parser.add_argument('-V', '--verbose', args = parser.parse_args() +GIT_DIR=".git" +if args.git_dir: + GIT_DIR="%s/.git" % (args.git_dir) + +if not os.path.exists(GIT_DIR): + fail("%s directory doesn't exist." %GIT_DIR) + sys.exit(1) + if args.git_dir: try: with open(os.devnull, 'w') as null: From 65c25e10639bdd4e1731df6e6c70b942e148e99a Mon Sep 17 00:00:00 2001 From: Marko Saukko Date: Wed, 8 May 2013 12:27:11 +0300 Subject: [PATCH 2/3] Initialize the git tree properly when ever --auto is used. Signed-off-by: Marko Saukko --- gp_setup | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gp_setup b/gp_setup index 4ae216d..21b5a69 100755 --- a/gp_setup +++ b/gp_setup @@ -132,8 +132,6 @@ use_existing() { # Would be nice to default to tag=version unpack=true basetag=${1#*=} - # Make a git repo if there isn't one - if ! [[ -d .git ]]; then git init; fi shift ;; --pkgdir=* ) pkgdir=${1#*=} @@ -156,11 +154,6 @@ use_existing() { esac done - # If --unpack-to didn't make one then complain if we're not in a git repo - [[ -d .git ]] || { - fatal "This is not a git repository; use gp_setup when you've cloned or created a normal src repo that is ready for packaging". - } - [[ $pkgdir ]] || { fatal "You must supply --pkgdir when using --auto"; } [[ -d $pkgdir ]] || { fatal "Supplied --pkgdir '$pkgdir' is not a directory"; } # Determine version/release numbers @@ -195,8 +188,14 @@ use_existing() { pbranch="${DISTRO}-master" - if ! [[ -d .git ]]; then - fatal "This is not a git repository" + # Make sure we have git tree initialized. + if ! [[ -d .git ]]; then + git init + fi + + # Make sure there is at least one commit on the git tree. + if [[ "$(git branch | wc -l)" -eq "0" ]]; then + git commit -s --allow-empty -m "Initialized git repository." fi # Verify there's only a single spec or yaml file. From 685e60847522319fc4c86c1cff62ba6da646d44a Mon Sep 17 00:00:00 2001 From: Marko Saukko Date: Wed, 8 May 2013 09:35:47 +0000 Subject: [PATCH 3/3] Catch exception and exit properly when pkg-mer branch is not found. Signed-off-by: Marko Saukko --- gp_mkpkg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gp_mkpkg b/gp_mkpkg index b481b89..b169e79 100755 --- a/gp_mkpkg +++ b/gp_mkpkg @@ -60,8 +60,10 @@ def checkout_packaging_branch(pkg, force): spec etc so the patch-sets can be added.) """ if force: - git('checkout', '-f', pkg) - + try: + git('checkout', '-f', pkg) + except: + fail("Unable to checkout '%s' branch." % (pkg)) try: branch = git('symbolic-ref', 'HEAD').replace('refs/heads/', '').rstrip() except subprocess.CalledProcessError: