f12fc74080918d53cf90175c7cdcbf38fc9fe010
[feisty_meow.git] / scripts / rev_control / push_repo_downstream.sh
1 #!/bin/bash
2
3 # this script works on a specialized type of git checkout that has been configured
4 # to push to a "downstream" repository, while still pulling from its normal origin.
5 # the downstream destination might be a github or sourceforge repository that is
6 # loaded from a personal repository or server.
7 #
8 # it is assumed that you have already added your ssh key to your github account.
9 #
10 # to set up the repository for relaying downstream, just do the normal checkout
11 # or clone on it from the real origin.  for example:
12 #
13 # $ git clone git://feistymeow.org/feisty_meow feisty_relay
14 #
15 # change into that new directory:
16 #
17 # $ pushd feisty_relay
18 #
19 # and then add the downstream remote repository:
20 #
21 # # github example of add:
22 # $ git remote add downstream git@github.com:fredhamster/feisty_meow.git
23 #
24 # # sourceforge example of add:
25 # $ git remote add downstream ssh://fred_t_hamster@git.code.sf.net/p/feistymeow/trunk
26 #
27 # once the repository has been created, you can synch all updates that
28 # have been checked into the origin repository with the downstream version
29 # by running this command:
30 #
31 # push_repo_downstream ~/relay_repo_folder
32
33 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
34 source "$FEISTY_MEOW_SCRIPTS/rev_control/version_control.sh"
35
36 save_terminal_title
37
38 # turn off occasionally troublesome setting before checkin.
39 unset GIT_SSH
40
41 ##############
42
43 dir="$1"; shift
44 if [ -z "$dir" ]; then
45   dir=.
46 fi
47
48 pushd "$dir" &>/dev/null
49 exit_on_error "changing to directory: $dir"
50 tempfile=$(generate_rev_ctrl_filelist)
51 exit_on_error "generating revision control file list"
52
53 perform_revctrl_action_on_file "$tempfile" do_revctrl_careful_update
54 exit_on_error "doing a careful update on: $tempfile"
55
56 # seems to be needed to cause a merge to be resolved.
57 git pull downstream master
58 # -m "unfortunate merge"
59 exit_on_error "running the git pull downstream master"
60
61 # send our little boat down the stream to the dependent repository.
62 git push --tags downstream master
63 exit_on_error "running the git push downstream master"
64
65 # do our dev branch also.
66 git push --tags downstream dev
67 continue_on_error "running the git push downstream dev: is there a dev branch?"
68
69 popd &>/dev/null
70
71 restore_terminal_title