This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
MIT License | |
Copyright (c) 2016 Matt Menzenski | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for /f %%i in ('git rev-parse --abbrev-ref HEAD| sed "sI.*/IIg"') do set branch=%%i | |
git show-branch 2> nul | grep '\*' | grep -v "%branch%" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//' | |
# How it works: | |
# 1| Display a textual history of all commits. | |
# 2| Ancestors of the current commit are indicated | |
# by a star. Filter out everything else. | |
# 3| Ignore all the commits in the current branch. | |
# 4| The first result will be the nearest ancestor branch. |