diff --git a/README.md b/README.md index 936558a..b9306fe 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,14 @@ repo, follow the instructions according to your operating system: Copy the two script files to `/usr/local/bin`. That's it. -### Windows (with Bash shell) ### +### Windows ### On Windows with Msysgit, you can copy them into `C:\Program Files (x86)\Git\bin`. Following caveats: - You will probably have to replace the shebang line with `#!c:\python34\python.exe` or wherever else you have Python 3 installed. - - You can only run these scripts from the ~Git Bash~. If you haven't installed Msysgit with `Git Bash Here` option, invoke `bin\bash.exe`. + - You can only run these scripts from the Git Bash. If you haven't installed Msysgit with `Git Bash Here` option, invoke `bin\bash.exe`. - You have to run `git-cascade` and `git-forward-merge` instead of `git cascade` and `git forward-merge` due to Windows shenanigans. @@ -123,6 +123,14 @@ If only one argument is specified, git cascade will assume you want to cascade Will cascade `HEAD` into `staging` and all of its dependents. +If no arguments are specified: + + git cascade + +Then HEAD will be cascaded into the current branch. (It's often useful to +cascade a branch into itself because it also merges it into the branches it +flows into.) + How does it work? ----------------- @@ -239,4 +247,5 @@ Copyright and license ===================== Both scripts are copyright 2009-2014 Ram Rachum and are released under the MIT -license. +license. I provide +[development services in Python and Django](https://chipmunkdev.com). diff --git a/git-cascade b/git-cascade index a7b8aa7..e5e855d 100755 --- a/git-cascade +++ b/git-cascade @@ -88,6 +88,14 @@ If only one argument is specified, git cascade will assume you want to cascade Will cascade `HEAD` into `staging` and all of its dependents. +If no arguments are specified: + + git cascade + +Then HEAD will be cascaded into the current branch. (It's often useful to +cascade a branch into itself because it also merges it into the branches it +flows into.) + How does it work? ----------------- @@ -132,12 +140,14 @@ And then run: git cascade foo m It will cascade `foo` into `master` and all of its dependents. + +Also, you may use `.` as an alias for the current branch. ''' VersionInfo = collections.namedtuple('VersionInfo', 'major minor micro release') -__version__ = '0.1' -__version_info__ = VersionInfo(0, 0, 1, 'alpha') +__version__ = '0.3' +__version_info__ = VersionInfo(0, 3, 0, 'alpha') def run(command, show=True, assert_success=True, env=None): popen = subprocess.Popen( @@ -199,10 +209,16 @@ alias_strings = [line[19:] for line in config_lines if aliases_dict = dict( alias_string.split('=', 1) for alias_string in alias_strings ) -expand_alias = lambda branch: aliases_dict.get(branch, branch) +def expand_branch_name(short_branch_name): + if short_branch_name == '.': + return current_branch + else: + return aliases_dict.get(short_branch_name, short_branch_name) # # ############################################################################### +current_branch = run('git rev-parse --abbrev-ref HEAD') + ### Organizing cascades: ###################################################### # # @@ -263,10 +279,11 @@ for cascade_string in cascade_strings: ### Analyzing input to get source and destinations: ########################### # # -branches = tuple(map(expand_alias, map(str.strip, sys.argv[1:]))) +branches = tuple(map(expand_branch_name, map(str.strip, sys.argv[1:]))) if not branches: - show_help_and_exit() -if len(branches) == 1: + global_source = 'HEAD' + global_destinations = {current_branch} +elif len(branches) == 1: global_source = 'HEAD' global_destinations = {branches[0]} else: diff --git a/git-forward-merge b/git-forward-merge index ccd422c..19f99c1 100755 --- a/git-forward-merge +++ b/git-forward-merge @@ -78,12 +78,14 @@ And then run: git forward-merge s m It will merge `staging` into `master`. + +Also, you may use `.` as an alias for the current branch. ''' VersionInfo = collections.namedtuple('VersionInfo', 'major minor micro release') -__version__ = '0.1' -__version_info__ = VersionInfo(0, 0, 1, 'alpha') +__version__ = '0.3' +__version_info__ = VersionInfo(0, 3, 0, 'alpha') @contextlib.contextmanager def create_temp_folder(): @@ -143,14 +145,19 @@ alias_strings = [line[19:] for line in config_lines if aliases_dict = dict( alias_string.split('=', 1) for alias_string in alias_strings ) -expand_alias = lambda branch: aliases_dict.get(branch, branch) +def expand_branch_name(short_branch_name): + if short_branch_name == '.': + return current_branch + else: + return aliases_dict.get(short_branch_name, short_branch_name) # # ############################################################################### +current_branch = run('git rev-parse --abbrev-ref HEAD') ### Analyzing input to get source and destinations: ########################### # # -branches = tuple(map(expand_alias, map(str.strip, sys.argv[1:]))) +branches = tuple(map(expand_branch_name, map(str.strip, sys.argv[1:]))) if not branches: show_help_and_exit() if len(branches) == 1: @@ -163,8 +170,6 @@ else: # # ### Finished analyzing input to get source and destinations. ################## -current_branch = run('git rev-parse --abbrev-ref HEAD') - print('Pushing %s' % (', '.join( (('%s -> %s' % (source, destination)) for destination in destinations))))