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

Side by Side Diff: gclient_scm.py

Issue 505007: gclient: Add better error reporting when path is not a git repo. (Closed)
Patch Set: Added a test Created 10 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 if not os.path.exists(self.checkout_path): 181 if not os.path.exists(self.checkout_path):
182 self._Run(['clone', url, self.checkout_path], 182 self._Run(['clone', url, self.checkout_path],
183 cwd=self._root_dir, redirect_stdout=False) 183 cwd=self._root_dir, redirect_stdout=False)
184 if revision: 184 if revision:
185 self._Run(['reset', '--hard', revision], redirect_stdout=False) 185 self._Run(['reset', '--hard', revision], redirect_stdout=False)
186 files = self._Run(['ls-files']).split() 186 files = self._Run(['ls-files']).split()
187 file_list.extend([os.path.join(self.checkout_path, f) for f in files]) 187 file_list.extend([os.path.join(self.checkout_path, f) for f in files])
188 return 188 return
189 189
190 if not os.path.exists(os.path.join(self.checkout_path, '.git')):
191 raise gclient_utils.Error('\n____ %s%s\n'
192 '\tPath is not a git repo. No .git dir.\n'
193 '\tTo resolve:\n'
194 '\t\trm -rf %s\n'
195 '\tAnd run gclient sync again\n'
196 % (self.relpath, rev_str, self.relpath))
197
190 new_base = 'origin' 198 new_base = 'origin'
191 if revision: 199 if revision:
192 new_base = revision 200 new_base = revision
193 cur_branch = self._GetCurrentBranch() 201 cur_branch = self._GetCurrentBranch()
194 202
195 # Check if we are in a rebase conflict 203 # Check if we are in a rebase conflict
196 if cur_branch is None: 204 if cur_branch is None:
197 raise gclient_utils.Error('\n____ %s%s\n' 205 raise gclient_utils.Error('\n____ %s%s\n'
198 '\tAlready in a conflict, i.e. (no branch).\n' 206 '\tAlready in a conflict, i.e. (no branch).\n'
199 '\tFix the conflict and run gclient again.\n' 207 '\tFix the conflict and run gclient again.\n'
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " 547 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory "
540 "does not exist." 548 "does not exist."
541 % (' '.join(command), path)) 549 % (' '.join(command), path))
542 # There's no file list to retrieve. 550 # There's no file list to retrieve.
543 else: 551 else:
544 self.RunAndGetFileList(options, command, path, file_list) 552 self.RunAndGetFileList(options, command, path, file_list)
545 553
546 def FullUrlForRelativeUrl(self, url): 554 def FullUrlForRelativeUrl(self, url):
547 # Find the forth '/' and strip from there. A bit hackish. 555 # Find the forth '/' and strip from there. A bit hackish.
548 return '/'.join(self.url.split('/')[:4]) + url 556 return '/'.join(self.url.split('/')[:4]) + url
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698