podman
61 строка · 1.8 Кб
1#!/bin/bash
2#
3# This script is intended to help developers get buildah-tests-under-podman
4# working again in case of failure.
5#
6ME=$(basename $0)
7
8die() {
9echo "$ME: $*" >&2
10exit 1
11}
12
13# Confirm that we're in a test-buildah* subdir of podman
14whereami=$(basename $(pwd))
15if [[ ! $whereami =~ test-buildah-v ]]; then
16die "Please run me while cd'ed to a test-buildah-vN.M directory"
17fi
18
19# FIXME: check that git repo is buildah
20git remote -v | grep -q '[BUILDAHREPO]' \
21|| die "This does not look like a buildah repo (git remote -v)"
22
23# We could do the commit automatically, but it's prudent to require human
24# involvement.
25modified=$(git status --untracked=no --porcelain)
26if [[ -n "$modified" ]]; then
27echo $modified
28die "Please commit your changes: git commit --amend --all"
29fi
30
31# Remove any 00??-*.patch files
32rm -f 0001-*.patch
33
34# Check count of commits, barf if need to squash
35n_commits=$(git log --pretty=format:%h [BASETAG]..HEAD | wc -l)
36if [[ $n_commits -gt 1 ]]; then
37die "Please squash your commits"
38fi
39
40# Scope check: make sure the only files changed is helpers.bash
41changes=$(git diff --name-status [BASETAG]..HEAD | grep -E -v '\stests/helpers.bash')
42if [[ -n "$changes" ]]; then
43echo $changes
44die "Found modified files other than 'tests/helpers.bash'"
45fi
46
47###############################################################################
48# All right - things look good. Generate the patch, and copy it into place.
49
50git format-patch [BASETAG]
51
52# Once again, make sure there's exactly one and only one commit
53shopt -s nullglob
54patch2=$(echo 0002-*.patch)
55if [[ -n "$patch2" ]]; then
56die "Internal error: I thought I checked for squashed commits, but still see $patch2"
57fi
58
59# All looks good. We can now copy that patch into its proper place in the
60# podman repo.
61cp 0001-*.patch ../test/buildah-bud/buildah-tests.diff
62