github.com/containers/podman/v5@v5.1.0-rc1/test/buildah-bud/make-new-buildah-diffs (about)

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