def clone_strategy(directory): cmd_output( 'git', 'clone', '--no-checkout', repo, directory, env=no_git_env(), ) with cwd(directory): cmd_output('git', 'reset', ref, '--hard', env=no_git_env())
def clone(self, url, sha): """Clone the given url and checkout the specific sha.""" self.require_created() # Check if we already exist with sqlite3.connect(self.db_path) as db: result = db.execute( 'SELECT path FROM repos WHERE repo = ? AND ref = ?', [url, sha], ).fetchone() if result: return result[0] logger.info('Initializing environment for {}.'.format(url)) dir = tempfile.mkdtemp(prefix='repo', dir=self.directory) with clean_path_on_failure(dir): cmd_output( 'git', 'clone', '--no-checkout', url, dir, env=no_git_env(), ) with cwd(dir): cmd_output('git', 'reset', sha, '--hard', env=no_git_env()) # Update our db with the created repo with sqlite3.connect(self.db_path) as db: db.execute( 'INSERT INTO repos (repo, ref, path) VALUES (?, ?, ?)', [url, sha, dir], ) return dir
def clone(self, url, sha): """Clone the given url and checkout the specific sha.""" self.require_created() # Check if we already exist with sqlite3.connect(self.db_path) as db: result = db.execute( 'SELECT path FROM repos WHERE repo = ? AND ref = ?', [url, sha], ).fetchone() if result: return result[0] logger.info('Initializing environment for {0}.'.format(url)) dir = tempfile.mkdtemp(prefix='repo', dir=self.directory) with clean_path_on_failure(dir): cmd_output( 'git', 'clone', '--no-checkout', url, dir, env=no_git_env(), ) with cwd(dir): cmd_output('git', 'reset', sha, '--hard', env=no_git_env()) # Update our db with the created repo with sqlite3.connect(self.db_path) as db: db.execute( 'INSERT INTO repos (repo, ref, path) VALUES (?, ?, ?)', [url, sha, dir], ) return dir
def clone_strategy(directory): cmd_output( 'git', 'clone', '--no-checkout', repo, directory, env=no_git_env(), ) with cwd(directory): cmd_output('git', 'reset', ref, '--hard', env=no_git_env())
def clone_strategy(directory): cmd_output( 'git', 'clone', '--no-checkout', '--depth', '1', repo, directory, env=no_git_env(), ) with cwd(directory): cmd_output('git', 'reset', ref, '--hard', env=no_git_env()) cmd_output( 'git', 'submodule', 'update', '--init', '--recursive', env=no_git_env(), )
def clone_strategy(directory): cmd_output( 'git', 'clone', '--no-checkout', repo, directory, env=no_git_env(), ) with cwd(directory): cmd_output('git', 'reset', ref, '--hard', env=no_git_env()) cmd_output( 'git', 'submodule', 'update', '--init', '--recursive', env=no_git_env(), )
def clone_strategy(directory): env = no_git_env() def _git_cmd(*args): return cmd_output('git', '-C', directory, *args, env=env) _git_cmd('clone', '--no-checkout', repo, '.') _git_cmd('reset', ref, '--hard') _git_cmd('submodule', 'update', '--init', '--recursive')
def make_local_strategy(directory): copy_tree_to_path(resource_filename('empty_template'), directory) env = no_git_env() name, email = 'pre-commit', '*****@*****.**' env['GIT_AUTHOR_NAME'] = env['GIT_COMMITTER_NAME'] = name env['GIT_AUTHOR_EMAIL'] = env['GIT_COMMITTER_EMAIL'] = email # initialize the git repository so it looks more like cloned repos def _git_cmd(*args): cmd_output('git', '-C', directory, *args, env=env) _git_cmd('init', '.') _git_cmd('config', 'remote.origin.url', '<<unknown>>') _git_cmd('add', '.') _git_cmd('commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')
def make_local_strategy(directory): for resource in self.LOCAL_RESOURCES: contents = resource_text('empty_template_{}'.format(resource)) with io.open(os.path.join(directory, resource), 'w') as f: f.write(contents) env = no_git_env() name, email = 'pre-commit', '*****@*****.**' env['GIT_AUTHOR_NAME'] = env['GIT_COMMITTER_NAME'] = name env['GIT_AUTHOR_EMAIL'] = env['GIT_COMMITTER_EMAIL'] = email # initialize the git repository so it looks more like cloned repos def _git_cmd(*args): cmd_output('git', *args, cwd=directory, env=env) _git_cmd('init', '.') _git_cmd('config', 'remote.origin.url', '<<unknown>>') _git_cmd('add', '.') _git_cmd('commit', '--no-edit', '--no-gpg-sign', '-n', '-minit')