|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -eux |
| 4 | + |
| 5 | +TARGETDIR="$1" |
| 6 | +cd "$TARGETDIR" |
| 7 | +if [ -e "foo" ] && [ -e "foorepo" ]; then |
| 8 | + echo "Repository already exists" |
| 9 | + exit 0 |
| 10 | +fi |
| 11 | + |
| 12 | +SvnCommit() { |
| 13 | + local MESSAGE="$1" |
| 14 | + local USERNAME=${2:-Alice} |
| 15 | + svn ci --username "$USERNAME" -m "$MESSAGE" |
| 16 | +} |
| 17 | + |
| 18 | +svnadmin create foorepo |
| 19 | +svn co "file://$(readlink -f foorepo)" foo |
| 20 | +cd foo |
| 21 | + |
| 22 | +svn mkdir trunk branches tags |
| 23 | +SvnCommit 'initial' |
| 24 | + |
| 25 | +( # create project |
| 26 | +set -e |
| 27 | +cd trunk |
| 28 | +cat > Makefile << 'EOF' |
| 29 | +.PHONY: libfoo exe |
| 30 | +all: exe |
| 31 | +libfoo: |
| 32 | + $(MAKE) -C libfoo |
| 33 | +exe: libfoo |
| 34 | + $(MAKE) -C exe |
| 35 | +EOF |
| 36 | +mkdir libfoo exe |
| 37 | +cat > libfoo/Makefile << 'EOF' |
| 38 | +all: |
| 39 | + cc *.c -o libfoo.so -shared |
| 40 | +EOF |
| 41 | +echo 'const char* get_foo_string();' > libfoo/libfoo.h |
| 42 | +cat > libfoo/libfoo.c << 'EOF' |
| 43 | +const char* get_foo_string() { |
| 44 | + return "foooooo"; |
| 45 | +} |
| 46 | +EOF |
| 47 | +cat > exe/Makefile << 'EOF' |
| 48 | +all: |
| 49 | + cc *.c -o foo -L ../libfoo/ -lfoo |
| 50 | +EOF |
| 51 | +cat > exe/foo.c << 'EOF' |
| 52 | +#include <stdio.h> |
| 53 | +#include "../libfoo/libfoo.h" |
| 54 | +
|
| 55 | +int main() { |
| 56 | + puts(get_foo_string()); |
| 57 | +} |
| 58 | +EOF |
| 59 | +svn add ./* |
| 60 | +SvnCommit "$(echo -e 'Project created\nlibrary foo\nand exe')" |
| 61 | +) |
| 62 | + |
| 63 | +( |
| 64 | +set -e |
| 65 | +cd trunk |
| 66 | +echo "// dummy comment" >> libfoo/libfoo.c |
| 67 | +SvnCommit "add comment" Bob |
| 68 | +echo 'const char* get_foo_string();' > libfoo/libfoo.h |
| 69 | +cat > libfoo/libfoo.h << 'EOF' |
| 70 | +#ifndef LIBFOO |
| 71 | +#define LIBFOO |
| 72 | +const char* get_foo_string(); |
| 73 | +#endif |
| 74 | +EOF |
| 75 | +SvnCommit "fix header" Bob |
| 76 | +) |
| 77 | + |
| 78 | +( |
| 79 | +set -e |
| 80 | +svn cp ^/trunk ^/branches/feature1 -m "create branch" |
| 81 | +svn up |
| 82 | +cd branches/feature1 |
| 83 | +echo "// another dummy comment" >> libfoo/libfoo.c |
| 84 | +echo "# another dummy comment" >> libfoo/Makefile |
| 85 | +SvnCommit "comment" Mark |
| 86 | +svn mv exe/foo.c exe/exefoo.c |
| 87 | +echo '// edited! ' >> exe/exefoo.c |
| 88 | +SvnCommit "rename exe" Mark |
| 89 | +) |
| 90 | + |
| 91 | +( |
| 92 | +set -e |
| 93 | +cd trunk |
| 94 | +echo "# Alice's comment" >> exe/Makefile |
| 95 | +SvnCommit "comment by Alice" |
| 96 | +) |
| 97 | + |
| 98 | +( |
| 99 | +set -e |
| 100 | +cd branches/feature1 |
| 101 | +svn up |
| 102 | +svn merge ^/trunk |
| 103 | +SvnCommit "sync with trunk" Mark |
| 104 | +) |
| 105 | + |
| 106 | +( |
| 107 | +set -e |
| 108 | +cd trunk |
| 109 | +svn up |
| 110 | +svn merge ^/branches/feature1 |
| 111 | +SvnCommit "merge feature1 to trunk" Mark |
| 112 | +svn rm ^/branches/feature1 -m "rm branch" |
| 113 | +) |
| 114 | + |
| 115 | +svn up |
0 commit comments