From a5e9d2775acb1ac507be664e3ef3da119c6183e3 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 11 Nov 2008 16:58:53 -0600 Subject: [PATCH] Remove cruft hooks, including the dreaded update-prefer-rebase. --- server/noop | 3 - server/pre-receive-only-one | 16 -- server/pre-receive-trac.py | 63 -------- server/update-ensure-merged | 107 ------------- server/update-prefer-rebase | 82 ---------- server/update-prefer-underscores | 20 --- .../t2101-update-stable-and-prefer-rebased.sh | 47 ------ tests/t2300-update-prefer-rebase.sh | 107 ------------- ...301-update-prefer-rebase-even-if-merges.sh | 145 ------------------ .../t2302-update-prefer-rebase-new-parent.sh | 113 -------------- tests/t2400-pre-receive-only-one.sh | 49 ------ tests/t2500-update-ensure-merged.sh | 88 ----------- tests/t2600-update-prefer-underscores.sh | 39 ----- 13 files changed, 879 deletions(-) delete mode 100644 server/noop delete mode 100644 server/pre-receive-only-one delete mode 100644 server/pre-receive-trac.py delete mode 100644 server/update-ensure-merged delete mode 100644 server/update-prefer-rebase delete mode 100644 server/update-prefer-underscores delete mode 100644 tests/t2101-update-stable-and-prefer-rebased.sh delete mode 100644 tests/t2300-update-prefer-rebase.sh delete mode 100644 tests/t2301-update-prefer-rebase-even-if-merges.sh delete mode 100644 tests/t2302-update-prefer-rebase-new-parent.sh delete mode 100644 tests/t2400-pre-receive-only-one.sh delete mode 100644 tests/t2500-update-ensure-merged.sh delete mode 100644 tests/t2600-update-prefer-underscores.sh diff --git a/server/noop b/server/noop deleted file mode 100644 index 829303e..0000000 --- a/server/noop +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - - diff --git a/server/pre-receive-only-one b/server/pre-receive-only-one deleted file mode 100644 index 819167a..0000000 --- a/server/pre-receive-only-one +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -i=0 -while read oldrev newrev refname ; do - i=$(($i + 1)) -done - -if [ $i -ne 1 ] ; then - echo "----------------------------------------------------" - echo - echo "Only push one branch at a time" - echo - echo "----------------------------------------------------" - exit 1 -fi - diff --git a/server/pre-receive-trac.py b/server/pre-receive-trac.py deleted file mode 100644 index 3d5a79d..0000000 --- a/server/pre-receive-trac.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso8859-1 -*- -# -# Author: Jonas Borgström -# -# This script will enforce the following policy: -# -# "A checkin must reference an open ticket." -# -# This script should be invoked from the subversion pre-commit hook like this: -# -# REPOS="$1" -# TXN="$2" -# TRAC_ENV="/somewhere/trac/project/" -# LOG=`/usr/bin/svnlook log -t "$TXN" "$REPOS"` -# /usr/bin/python /some/path/trac-pre-commit-hook "$TRAC_ENV" "$LOG" || exit 1 -# -import os -import re -import sys - -from trac.env import open_environment - -def main(): - if len(sys.argv) != 3: - print >> sys.stderr, 'Usage: %s ' % sys.argv[0] - sys.exit(1) - - env_path = sys.argv[1] - log = sys.argv[2].lower() - - # Stephen: exempt 'No ticket' - if re.search('no ticket', log) or re.search('initialized merge tracking', log): - sys.exit(0) - - tickets = [] - for tmp in re.findall('(?:refs|re|qa).?(#[0-9]+(?:(?:[, &]+| *and *)#[0-9]+)*)', log): - tickets += re.findall('#([0-9]+)', tmp) - - # At least one ticket has to be mentioned in the log message - if tickets == []: - print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.' - sys.exit(1) - - env = open_environment(env_path) - db = env.get_db_cnx() - - cursor = db.cursor() - # Stephen: let the tickets be closed for now - # cursor.execute("SELECT COUNT(id) FROM ticket WHERE status <> 'closed' AND id IN (%s)" % ','.join(tickets)) - cursor.execute("SELECT COUNT(id) FROM ticket WHERE id IN (%s)" % ','.join(tickets)) - row = cursor.fetchone() - if not row or row[0] < 1: - print >> sys.stderr, 'At least one open ticket must be mentioned in the log message.' - sys.exit(1) - else: - sys.exit(0) - -if __name__ == '__main__': - main() - - - diff --git a/server/update-ensure-merged b/server/update-ensure-merged deleted file mode 100644 index a83210a..0000000 --- a/server/update-ensure-merged +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -# -# When tagging the candidate branch, and commit "A" -# has gone onto a topic branch that we previously -# merged, reject the tag. -# -# * -- * -- * -- A topic A -# \ \ -# * -- * topic B -# \ \ -# * candidate -# -# We want to detect A when trying to tag candidate. -# -# This also implements candidate protection, e.g. -# only merges are allowed on candidate branches. - -# Command line -refname="$1" -oldrev="$2" -newrev="$3" - -echo "updating $refname $oldrev $newrev" -fail=0 - -case "$refname" in - refs/tags/*) - # First make sure stable hasn't moved on us - baserev=$(git merge-base stable $newrev) - stablerev=$(git rev-parse stable) - if [ "$baserev" != "$stablerev" ] ; then - echo "----------------------------------------------------" - echo - echo " Rejecting $refname because you need to merge:" - echo - git rev-list "$baserev..$stablerev" | xargs git name-rev - echo - echo "----------------------------------------------------" - fail=1 - else - - # Now go back to stable and iterate through looking for commits on - # our merge parents that are not within us - git rev-list --first-parent "stable..$newrev" | while read commit ; do - number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) - if [[ $number_of_parents > 1 ]] ; then - # For each parent - git rev-list --no-walk --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do - # Does this parent have any children besides us? - # - # List the parents of all branch commits (after stable/parent), find - # those that include our parent, get their sha1, remove our merge - git rev-list --parents --branches ^stable "^$parent" | grep $parent | gawk '{print $1}' | grep -v $commit | while read child ; do - number_missing=$(git rev-list "$child" "^$newrev" | wc -l) - if [[ $number_missing > 0 ]] ; then - echo "----------------------------------------------------" - echo - echo " Rejecting $refname because you need to merge:" - echo - git rev-list "$child" "^$newrev" | xargs git name-rev - echo - echo "----------------------------------------------------" - fail=1 - fi - done - - # Find any commits in the parent (and another branch) but not us--that means we need it - # number_missing=$(git rev-list "$parent" --all "^$newrev" | wc -l) - # if [[ $number_missing > 0 ]] ; then - # echo "----------------------------------------------------" - # echo - # echo " Rejecting $refname because you need to merge:" - # echo - # git rev-list "$parent" --all "^$newrev" | xargs git name-rev - # echo - # echo "----------------------------------------------------" - # exit 1 - # fi - done - fi - done - - fi - ;; - - refs/heads/candidate*) - # Look at commits between stable and us--ignoring those brought in by merges - git rev-list --first-parent "$newrev" ^stable | while read commit ; do - number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) - if [[ $number_of_parents == 1 ]] ; then - echo "----------------------------------------------------" - echo - echo " Candidate branches must be only merges" - echo - echo "----------------------------------------------------" - fail=1 - fi - done - ;; - - *) - ;; -esac - -exit "$fail" - diff --git a/server/update-prefer-rebase b/server/update-prefer-rebase deleted file mode 100644 index 464cb7e..0000000 --- a/server/update-prefer-rebase +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -# -# Watches for merges that had only local merges (e.g. should have been rebases). -# -# If they are introducing non-merge commits /and/ merge commits, it could -# look like one of two ways. This way: -# -# A -- B <-- origin/topic -# \ \ -# c -- d <-- topic -# -# They basically had an un-shared local dev branch (probably by making a -# merge) and instead should have done a rebase. Also, if they did: -# -# A -- B <-- origin/topic -# \ \ -# c -- d -- e <-- topic -# -# We should try and catch them--where the merge happened previously to -# them doing more work in the newrev commit. -# -# But if it looks like: -# -# A -- B <-- origin/foo -# \ \ -# C \ <-- origin/topic -# \ \ -# d -- e <-- topic -# -# Then they had a pre-shared branch that cannot be rebased and so they -# were correct in doing a merge to tie "old" and "oldrev" together. -# -# Also, we obviously have to be okay with: -# -# A -- B <-- origin/topic -# \ -# c -- d <-- topic - -. $(dirname $0)/functions - -refname="$1" -oldrev="$2" -newrev="$3" - -if expr "$oldrev" : '0*$' >/dev/null ; then - exit 0 -fi - -# Read backwards: all commits from old..new, unless they are already referenced by a branch -git rev-parse --not --branches | git rev-list --stdin $oldrev..$newrev | while read commit ; do - number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l) - if [[ $number_of_parents > 1 ]] ; then - # Hack to not interfer with the update-stable "--no-ff" method - if [[ "$refname" == "refs/heads/stable" && "$commit" == "$newrev" ]] ; then - exit 0 - fi - - # Find the original branch point (B) - parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit) - - # For each baserev - git merge-base --all $parents | while read baserev ; do - # For each parent - git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do - all_commits=$(git rev-list --first-parent $baserev..$parent | wc -l) - new_commits=$(git rev-parse --not --branches | git rev-list --stdin $baserev..$parent | wc -l) - if [ $all_commits -eq $new_commits ] ; then - # echo "parent=$parent" # echo "all_commits=$all_commits" # echo "new_commits=$new_commits" - display_error_message "It looks like you should rebase instead of merging $commit" - exit 1 - fi - done - if [ $? -ne 0 ] ; then - exit 1 - fi - done - if [ $? -ne 0 ] ; then - exit 1 - fi - fi -done - diff --git a/server/update-prefer-underscores b/server/update-prefer-underscores deleted file mode 100644 index db728dc..0000000 --- a/server/update-prefer-underscores +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# -# Simply enforces rate_tables instead of rateTables. Note -# that ratetables could still sneak when, but we'll give -# people the benefit of the doubt. - -. $(dirname $0)/functions - -# Command line -refname="$1" -oldrev="$2" -newrev="$3" - -if expr "$oldrev" : '0*$' >/dev/null ; then - if expr "$refname" : '.*[A-Z].*' ; then - display_error_message "Please use underscored branch names (e.g. rate_tables)" - exit 1 - fi -fi - diff --git a/tests/t2101-update-stable-and-prefer-rebased.sh b/tests/t2101-update-stable-and-prefer-rebased.sh deleted file mode 100644 index b82f853..0000000 --- a/tests/t2101-update-stable-and-prefer-rebased.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -test_description='server update stable enforcer still works with prefer rebased' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo setup >a && - git add a && - git commit -m "a" && - git clone ./. server && - git remote add origin ./server && - rm -fr server/.git/hooks -' - -# setup the update hook -install_update_hook 'update-stable' 'update-prefer-rebase' - -test_expect_success 'initial stable commit works' ' - # do one stable-less commit - echo $test_name >a && - git commit -a -m "$test_name" && - git push origin master && - - git checkout -b stable && - git push origin stable && - git config --add branch.stable.remote origin && - git config --add branch.stable.merge refs/heads/stable -' - -test_expect_success 'accept merge' ' - # make one topic branch - git checkout -b topic1 stable && - echo $test_name >topic1 && - git add topic1 && - git commit -m "$test_name topic1" && - git push origin topic1 && - - # try merging topic1 into stable, which will get a merge commit, but - # it should have changes involved and so get rejected - git checkout stable && - git merge --no-ff topic1 && - git push -' - -test_done - diff --git a/tests/t2300-update-prefer-rebase.sh b/tests/t2300-update-prefer-rebase.sh deleted file mode 100644 index ccc8a2a..0000000 --- a/tests/t2300-update-prefer-rebase.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -test_description='server update prefer rebase' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch -' - -install_update_hook 'update-prefer-rebase' - -test_expect_success 'merge local changes is caught' ' - # make an outstanding change for us--but do not push - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1" && - - # have another client commit (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - - # go back to our client and it will merge in our changes - cd .. && - git pull && - merge=$(git rev-parse HEAD) && - - ! git push 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging $merge" && - git reset --hard origin/master -' - -test_expect_success 'merge local changes followed by more commits is caught' ' - # make an outstanding change for us--but do not push - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1" && - - # have another client commit (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - - # go back to our client and it will merge in our changes - cd .. && - git pull && - merge=$(git rev-parse HEAD) && - - # To complicate things, have them add another change - echo "$test_name again" >a.client1 && - git commit -a -m "$test_name on client1 again" && - - ! git push 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging $merge" && - git reset --hard origin/master -' - -test_expect_success 'merge shared changes from another topic is okay' ' - # make a change on topic for us and share it - git checkout -b topic master && - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1 and topic" && - git push origin topic && - - # make an outstanding on topic that is not pushed - echo "$test_name again" >>a.client1 && - git commit -a -m "$test_name on client1 and topic again" && - - # have another client commit to master (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - - # go back to our client and it will merge in our changes - cd .. && - git checkout master && - # this should fast fwd - git pull && - # this pulls in the shared branch+its new tip - git merge topic && - - git push -' - -test_expect_success 'simple commit' ' - # go back to topic and make a simple commit/push as a sanity check - git checkout topic && - echo "$test_name" >>a.client1 && - git commit -a -m "$test_name on client1 and topic" && - git push -' - -test_done - diff --git a/tests/t2301-update-prefer-rebase-even-if-merges.sh b/tests/t2301-update-prefer-rebase-even-if-merges.sh deleted file mode 100644 index fca8c30..0000000 --- a/tests/t2301-update-prefer-rebase-even-if-merges.sh +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh - -test_description='server update prefer rebase (with incoming merges)' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch && - - # Specifically, setup a stable that we will merge and check for rebase - git checkout -b stable master && - echo "setup.stable" >a && - git commit -a -m "stable" && - git push origin stable -' - -install_update_hook 'update-prefer-rebase' - -# -# A -- B <-- origin/stable -# \ | -# C -- D <-- origin/topic1 -# \ | \ -# e - f <-- topic1 -# -# Nope: should rebase e ontop of D -# -test_expect_success 'merging in stable does not fool the script' ' - # start our branch, and share it - git checkout -b topic1 stable && - git config --add branch.topic1.remote origin && - git config --add branch.topic1.merge refs/heads/topic1 && - echo "topic1" >a.topic1 && - git add a.topic1 && - git commit -m "topic1" && - git push origin topic1 && - - # now, separately, move ahead stable, and share it - git checkout stable - echo "setup.stable.moved" >a && - git commit -a -m "stable moved" && - git push origin stable && - - # have another client commit (in this case, it is the server, but close enough) move topic1 - cd server && - git checkout topic1 && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "topic1 changed by client2" && - cd .. && - - # now locally try and merge in stable (even though topic1 is out of date) - git checkout topic1 && - git merge stable && - - # We are shutdown for being a rewind - ! git push 2>push.err && - cat push.err | grep "[rejected] topic1 -> topic1 (non-fast forward)" - - # Make a new merge commit - git pull && - ! git push 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging" && - - # Now fix it - git reset --hard ORIG_HEAD && - GIT_EDITOR=: git rebase -i -p origin/topic1 && - git push && - git branch -r --contains stable | grep origin/topic -' - -# -# A --C------ <-- origin/stable -# \ | \ -# B -- D -- E -- F <-- origin/topic2 -# \| \ -# g -- h ------- i <-- topic2 -# -# Trying to push F..i -# -# merge-base(F, h) has two options: B and C -# -test_expect_success 'merging in stable with tricky double baserev does not fool the script' ' - # B: start our branch, and share it - git checkout -b topic2 stable && - git config --add branch.topic2.remote origin && - git config --add branch.topic2.merge refs/heads/topic2 && - echo "commit B" >a.topic2 && - git add a.topic2 && - git commit -m "commit B created topic2" && - git push origin topic2 && - - # C: now, separately, move ahead stable, and share it - git checkout stable - echo "commit C" >a && - git commit -a -m "commit C moved stable" && - git push origin stable && - - # D: have another client commit (in this case, it is the server, but close enough) moves topic2 - cd server && - git checkout topic2 && - # We might have cruft from the previous test - git reset --hard && - echo "commit D continuing topic2" >a.client2 && - git add a.client2 && - git commit -m "commit D by client2" && - - # E: another client merges stable - git merge stable && - - # F: another client moves topic2 again - echo "commit F" >a.client2 && - git commit -a -m "commit F by client2" && - cd .. && - - # g: now locally try and merge in stable (even though topic2 is out of date) - git checkout topic2 && - git merge stable && - - # h: advance local topic2 - echo "commit H" >a.topic2 && - git commit -a -m "commit H continues local fork" && - - # i: make a new merge commit - git pull && - ! git push origin topic2 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging" - - # Now fix it - # git reset --hard ORIG_HEAD && - # GIT_EDITOR=: git rebase -i -p origin/topic2 && - # git push && - # git branch -r --contains stable | grep origin/topic2 -' - -test_done - diff --git a/tests/t2302-update-prefer-rebase-new-parent.sh b/tests/t2302-update-prefer-rebase-new-parent.sh deleted file mode 100644 index b7f33e3..0000000 --- a/tests/t2302-update-prefer-rebase-new-parent.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/sh - -test_description='server update prefer rebase' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch -' - -install_update_hook 'update-prefer-rebase' - -test_expect_success 'one new, one old parent is okay' ' - # server is on "setup" - - # make an outstanding change for us--but do not push - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1" && - - # have another client commit (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - cd .. && - - # go back to our client and it will merge in our changes - git pull && - merge=$(git rev-parse HEAD) && - - ! git push 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging $merge" && - git reset --hard origin/master -' - -test_done - -test_expect_success 'all local changes do not need a merge even with more commits after' ' - # server is on "setup" - - # make an outstanding change for us--but do not push - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1" && - - # have another client commit (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - - # go back to our client and it will merge in our changes - cd .. && - git pull && - merge=$(git rev-parse HEAD) && - - # To complicate things, have them add another change - echo "$test_name again" >a.client1 && - git commit -a -m "$test_name on client1 again" && - - ! git push 2>push.err && - cat push.err | grep "It looks like you should rebase instead of merging $merge" && - git reset --hard origin/master -' - -test_expect_success 'already shared topic changes do warrant a merge' ' - # server is on "setup" - - # make a change on topic for us and share it - git checkout -b topic master && - echo "$test_name" >a.client1 && - git add a.client1 && - git commit -m "$test_name on client1 and topic" && - git push origin topic && - - # make an outstanding change that we will have to merge later - echo "$test_name again" >>a.client1 && - git commit -a -m "$test_name on client1 and topic again" && - - # have another client commit to master (in this case, it is the server, but close enough) - cd server && - echo "$test_name" >a.client2 && - git add a.client2 && - git commit -m "$test_name on client2" && - - # go back to our client and it will merge in our changes - cd .. && - git checkout master && - git pull && - git merge topic && - - git push -' - -test_expect_success 'simple commit' ' - # go back to topic and make a simple commit/push as a sanity check - git checkout topic && - echo "$test_name" >>a.client1 && - git commit -a -m "$test_name on client1 and topic" && - git push -' - -test_done - diff --git a/tests/t2400-pre-receive-only-one.sh b/tests/t2400-pre-receive-only-one.sh deleted file mode 100644 index 8a07a9f..0000000 --- a/tests/t2400-pre-receive-only-one.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh - -test_description='server pre-receive only one branch/push' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch -' - -install_server_hook 'pre-receive-only-one' 'pre-receive' - -test_expect_success 'pushing just topic is okay' ' - git checkout -b topic && - echo "$test_name" >a && - git commit -a -m "$test_name on topic" && - git push origin topic -' - -test_expect_success 'pushing just master is okay' ' - git checkout master && - echo "$test_name" >a && - git commit -a -m "$test_name on master" && - git push -' - -test_expect_success 'pushing both master and topic fails' ' - echo "$test_name" >a && - git commit -a -m "$test_name on master" && - - git checkout topic && - echo "$test_name" >a && - git commit -a -m "$test_name on topic" && - - ! git push 2>push.err && - cat push.err | grep "Only push one branch at a time" -' - - -test_done - diff --git a/tests/t2500-update-ensure-merged.sh b/tests/t2500-update-ensure-merged.sh deleted file mode 100644 index 83e1079..0000000 --- a/tests/t2500-update-ensure-merged.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh - -test_description='server update ensure merged' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch && - git checkout -b stable && - git push origin stable -' - -install_server_hook 'update-ensure-merged' 'update' - -test_expect_success 'pushing just topic is okay' ' - git checkout -b topic && - echo "$test_name" >a && - git commit -a -m "$test_name on topic" && - git push origin topic -' - -test_expect_failure 'if topic moves on, tagging candidate requires a merge' ' - git checkout -b candidate stable && - git merge topic --no-ff && - git push && - - git checkout topic && - echo "$test_name on topic" >a && - git commit -a -m "$test_name on topic" && - git push && - - git checkout candidate && - git tag -a -m "Tagging candidate" deployment-1 && - ! git push --tags 2>push.err && - cat push.err | grep "Rejecting refs/tags/deployment-1 because you need to merge" && - cat push.err | grep "topic" && - - git merge topic && - git tag -d deployment-1 && - git tag -a -m "Tagging candidate" deployment-1 && - git push --tags -' - -test_expect_success 'if stable moves on, tagging candidate requires a merge' ' - git checkout stable && - echo "$test_name on stable" >a.stable && - git add a.stable && - git commit -a -m "$test_name on stable" && - git push && - - git checkout candidate && - git tag -a -m "Tagging candidate" deployment-2 && - ! git push --tags 2>push.err && - cat push.err | grep "Rejecting refs/tags/deployment-2 because you need to merge" && - cat push.err | grep "stable" && - - git merge stable && - git tag -d deployment-2 && - git tag -a -m "Tagging candidate" deployment-2 && - git push --tags -' - -test_expect_failure 'when creating a candidate, it must be a merge' ' - git checkout -b topic2 stable && - echo "$test_name on topic2" >a && - git commit -a -m "$test_name on topic2" && - git push origin topic2 && - - git checkout -b candidate2 stable && - git merge topic2 && - ! git push origin candidate2 2>push.err && - cat push.err | grep "Candidate branches must be only merges" && - - git reset --hard HEAD^ && - git merge --no-ff topic2 && - git push origin candidate2 -' - -test_done - diff --git a/tests/t2600-update-prefer-underscores.sh b/tests/t2600-update-prefer-underscores.sh deleted file mode 100644 index f05a48c..0000000 --- a/tests/t2600-update-prefer-underscores.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -test_description='server update prefer underscores in branch names' - -. ./test-lib.sh - -test_expect_success 'setup' ' - echo "setup" >a && - git add a && - git commit -m "setup" && - git clone ./. server && - rm -fr server/.git/hooks && - git remote add origin ./server && - git config --add branch.master.remote origin && - git config --add branch.master.merge refs/heads/master && - git fetch && - git checkout -b stable && - git push origin stable -' - -install_update_hook 'update-prefer-underscores' - -test_expect_success 'pushing topic_topic works' ' - git checkout -b topic_topic && - echo "$test_name" >a && - git commit -a -m "$test_name on topic_topic" && - git push origin topic_topic -' - -test_expect_success 'pushing topicTopic fails' ' - git checkout -b topicTopic && - echo "$test_name" >a && - git commit -a -m "$test_name on topicTopic" && - ! git push origin topicTopic 2>push.err && - cat push.err | grep "Please use underscored branch names" -' - -test_done - -- 2.39.5