summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2011-02-09 15:39:10 -0700
committerJesse Keating <jkeating@redhat.com>2011-02-09 15:39:10 -0700
commit21ca17d3cd79e4f9887a51dff672cc0a47e11ae9 (patch)
treec7eaac6cbf6e40d522b9162f56c7befa8345ddf5
parentf4532e14662066aa0725932b6f861d9413ae76c3 (diff)
downloadfedora-packager-21ca17d3cd79e4f9887a51dff672cc0a47e11ae9.zip
fedora-packager-21ca17d3cd79e4f9887a51dff672cc0a47e11ae9.tar.gz
fedora-packager-21ca17d3cd79e4f9887a51dff672cc0a47e11ae9.tar.xz
Add a --rebase and --no-rebase option to pull
I decided to emulate git here and not default to a rebase.
-rwxr-xr-xsrc/fedpkg.py19
-rw-r--r--src/pyfedpkg/__init__.py14
2 files changed, 29 insertions, 4 deletions
diff --git a/src/fedpkg.py b/src/fedpkg.py
index 7c38249..56f3be2 100755
--- a/src/fedpkg.py
+++ b/src/fedpkg.py
@@ -639,7 +639,7 @@ def prep(args):
def pull(args):
try:
- pyfedpkg.pull(path=args.path)
+ pyfedpkg.pull(path=args.path, rebase=args.rebase, norebase=args.no_rebase)
except pyfedpkg.FedpkgError, e:
log.error('Could not pull: %s' % e)
sys.exit(1)
@@ -1227,7 +1227,22 @@ defined, packages will be built sequentially.""")
# Pull stuff
parser_pull = subparsers.add_parser('pull',
help = 'Pull changes from remote '
- 'repository and update working copy')
+ 'repository and update working copy.',
+ description = 'This command uses git \
+ to fetch remote changes and apply \
+ them to the current working copy. A \
+ rebase option is available which can \
+ be used to avoid merges.',
+ epilog = 'See git pull --help for \
+ more details')
+ parser_pull.add_argument('--rebase', action = 'store_true',
+ help = 'Rebase the locally committed changes on \
+ top of the remote changes after fetching. This \
+ can avoid a merge commit, but does rewrite local \
+ history.')
+ parser_pull.add_argument('--no-rebase', action = 'store_true',
+ help = 'Do not rebase, override .git settings to \
+ automatically rebase')
parser_pull.set_defaults(command = pull)
diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py
index 8696026..dcea285 100644
--- a/src/pyfedpkg/__init__.py
+++ b/src/pyfedpkg/__init__.py
@@ -710,12 +710,22 @@ def new(path=None):
log.debug('Diffing from tag %s' % tag)
return repo.git.diff('-M', tag)
-def pull(path=None):
- """Pull changes from the main repository using optional path"""
+def pull(path=None, rebase=False, norebase=False):
+ """Pull changes from the main repository using optional path
+
+ Optionally rebase current branch on top of upstream branch
+
+ Optionally override .git setting to always rebase
+
+ """
if not path:
path = os.getcwd()
cmd = ['git', 'pull']
+ if rebase:
+ cmd.append('--rebase')
+ if norebase:
+ cmd.append('--no-rebase')
_run_command(cmd, cwd=path)
return