diff --git a/gp_mkpkg b/gp_mkpkg index 495dbe0..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: @@ -314,6 +316,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: 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.