Skip to content

Please pull #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down Expand Up @@ -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?
-----------------
Expand Down Expand Up @@ -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).
29 changes: 23 additions & 6 deletions git-cascade
Original file line number Diff line number Diff line change
Expand Up @@ -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?
-----------------
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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: ######################################################
# #

Expand Down Expand Up @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions git-forward-merge
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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:
Expand All @@ -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))))

Expand Down