@contextmanager
def initialize_repo(worktree, gitdir=None):
 @contextmanager
 def use_gitdir():
  if gitdir:
   (yield gitdir)
  else:
   with temporary_dir() as d:
    (yield d)
 with use_gitdir() as git_dir:
  with environment_as(GIT_DIR=git_dir, GIT_WORK_TREE=worktree):
   subprocess.check_call([u'git', u'init'])
   subprocess.check_call([u'git', u'config', u'user.email', u'you@example.com'])
   subprocess.check_call([u'git', u'config', u'user.name', u'Your Name'])
   subprocess.check_call([u'git', u'add', u'.'])
   subprocess.check_call([u'git', u'commit', u'-am', u'Add project files.'])
   (yield Git(gitdir=git_dir, worktree=worktree))

@ contextmanager def initialize_repo ( worktree , gitdir = None ) : @ contextmanager def use_gitdir ( ) : if gitdir : ( yield gitdir ) else : with temporary_dir ( ) as d : ( yield d ) with use_gitdir ( ) as git_dir : with environment_as ( GIT_DIR = git_dir , GIT_WORK_TREE = worktree ) : subprocess . check_call ( [ u'git' , u'init' ] ) subprocess . check_call ( [ u'git' , u'config' , u'user.email' , u'you@example.com' ] ) subprocess . check_call ( [ u'git' , u'config' , u'user.name' , u'Your Name' ] ) subprocess . check_call ( [ u'git' , u'add' , u'.' ] ) subprocess . check_call ( [ u'git' , u'commit' , u'-am' , u'Add project files.' ] ) ( yield Git ( gitdir = git_dir , worktree = worktree ) )
initialize a git repository for the given worktree .