Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: gclient_scm.py

Issue 18006002: Add --upstream option to gclient to scrape git checkouts back to upstream state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: upstream not nuclear Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 2cdee7df8a1d7823678c9b19048890fe5c04f2c6..3e8f59c9ba837fb02eea5a3974bb96183c11e250 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -430,7 +430,10 @@ class GitWrapper(SCMWrapper):
# This is a big hammer, debatable if it should even be here...
if options.force or options.reset:
- self._Run(['reset', '--hard', 'HEAD'], options)
+ target = 'HEAD'
+ if options.upstream and upstream_branch:
+ target = upstream_branch
+ self._Run(['reset', '--hard', target], options)
if current_type == 'detached':
# case 0
@@ -578,6 +581,10 @@ class GitWrapper(SCMWrapper):
return self.update(options, [], file_list)
default_rev = "refs/heads/master"
+ if options.upstream:
+ if self._GetCurrentBranch():
+ upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path)
+ default_rev = upstream_branch or default_rev
_, deps_revision = gclient_utils.SplitUrlRevision(self.url)
if not deps_revision:
deps_revision = default_rev
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698