diff options
| author | Mike Frysinger <vapier@google.com> | 2020-03-22 13:54:55 -0400 |
|---|---|---|
| committer | Mike Frysinger <vapier@google.com> | 2020-03-23 00:31:10 +0000 |
| commit | 78964472adc5c92e0aad7bf513c50df5331d9d66 (patch) | |
| tree | 42b0024464f8f3bdc1548a3773bedb41ca3cf1d8 /subcmds/download.py | |
| parent | 05097c622231eeb095c17c5f5c4e791c57f382bc (diff) | |
| download | git-repo-78964472adc5c92e0aad7bf513c50df5331d9d66.tar.gz | |
download: add a --branch option
This allows people to quickly create new branches when pulling down
changes rather than having to juggle the git calls themselves.
Bug: https://crbug.com/gerrit/11609
Change-Id: Ie6a4d05e9f4e9347fe7f7119c768e6446563ae65
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/259855
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/download.py')
| -rw-r--r-- | subcmds/download.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/subcmds/download.py b/subcmds/download.py index badd9ab3..723124fd 100644 --- a/subcmds/download.py +++ b/subcmds/download.py | |||
| @@ -37,6 +37,8 @@ If no project is specified try to use current directory as a project. | |||
| 37 | """ | 37 | """ |
| 38 | 38 | ||
| 39 | def _Options(self, p): | 39 | def _Options(self, p): |
| 40 | p.add_option('-b', '--branch', | ||
| 41 | help='create a new branch first') | ||
| 40 | p.add_option('-c', '--cherry-pick', | 42 | p.add_option('-c', '--cherry-pick', |
| 41 | dest='cherrypick', action='store_true', | 43 | dest='cherrypick', action='store_true', |
| 42 | help="cherry-pick instead of checkout") | 44 | help="cherry-pick instead of checkout") |
| @@ -119,6 +121,11 @@ If no project is specified try to use current directory as a project. | |||
| 119 | else: | 121 | else: |
| 120 | mode = 'checkout' | 122 | mode = 'checkout' |
| 121 | 123 | ||
| 124 | # We'll combine the branch+checkout operation, but all the rest need a | ||
| 125 | # dedicated branch start. | ||
| 126 | if opt.branch and mode != 'checkout': | ||
| 127 | project.StartBranch(opt.branch) | ||
| 128 | |||
| 122 | try: | 129 | try: |
| 123 | if opt.cherrypick: | 130 | if opt.cherrypick: |
| 124 | project._CherryPick(dl.commit, ffonly=opt.ffonly, | 131 | project._CherryPick(dl.commit, ffonly=opt.ffonly, |
| @@ -128,7 +135,10 @@ If no project is specified try to use current directory as a project. | |||
| 128 | elif opt.ffonly: | 135 | elif opt.ffonly: |
| 129 | project._FastForward(dl.commit, ffonly=True) | 136 | project._FastForward(dl.commit, ffonly=True) |
| 130 | else: | 137 | else: |
| 131 | project._Checkout(dl.commit) | 138 | if opt.branch: |
| 139 | project.StartBranch(opt.branch, revision=dl.commit) | ||
| 140 | else: | ||
| 141 | project._Checkout(dl.commit) | ||
| 132 | 142 | ||
| 133 | except GitError: | 143 | except GitError: |
| 134 | print('[%s] Could not complete the %s of %s' | 144 | print('[%s] Could not complete the %s of %s' |
