summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-08-11 21:51:42 -0700
committerJesse Keating <jkeating@redhat.com>2010-08-11 22:09:06 -0700
commit493198a832ffbc240681c088fe1f92bc3077ed93 (patch)
treee9c84fbf9893c990d9e63d8a9758783b3972736c
parent698c9e70460f0f74f3ed6872d9ae865e182aa739 (diff)
downloadfedora-packager-493198a832ffbc240681c088fe1f92bc3077ed93.tar.gz
fedora-packager-493198a832ffbc240681c088fe1f92bc3077ed93.tar.xz
fedora-packager-493198a832ffbc240681c088fe1f92bc3077ed93.zip
Make switch-branches indiciate the current branch
Ticket #42 Some ugly string work here...
-rwxr-xr-xsrc/fedpkg.py9
-rw-r--r--src/pyfedpkg/__init__.py11
2 files changed, 18 insertions, 2 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index aab1373..a216abb 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -617,8 +617,13 @@ def switch_branch(args):
except pyfedpkg.FedpkgError, e:
log.error('Unable to list branches: %s' % e)
sys.exit(1)
- print('Locals:\n %s\nRemotes:\n %s' %
- ('\n '.join(locals), '\n '.join(remotes)))
+ # This is some ugly stuff here, but trying to emulate
+ # the way git branch looks
+ locals = [' %s ' % branch for branch in locals]
+ local_branch = pyfedpkg._find_branch(args.path)
+ locals[locals.index(' %s ' % local_branch)] = '* %s' % local_branch
+ print('Locals:\n%s\nRemotes:\n %s' %
+ ('\n'.join(locals), '\n '.join(remotes)))
def tagrequest(args):
# not implimented
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index faa1b86..269fe9d 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -57,6 +57,17 @@ log = logging.getLogger("fedpkg")
# Add the null handler
log.addHandler(h)
+def _find_branch(path=os.getcwd(), repo=None):
+ """Returns the active branch name"""
+
+ # Create the repo from path if no repo passed
+ if not repo:
+ try:
+ repo = git.Repo(path)
+ except:
+ raise FedpkgError('Invalid repo %s' % path)
+ return(repo.active_branch.name)
+
# Define some helper functions, they start with _
def _hash_file(file, hashtype):
"""Return the hash of a file given a hash type"""