Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions gp_mkpkg
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 8 additions & 9 deletions gp_setup
Original file line number Diff line number Diff line change
Expand Up @@ -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#*=}
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down