Ejemplo n.º 1
0
def init(args):
  
  if not git.is_controlled():
    print_color('fatal: Not a git repository', colors.FAIL)
    quit()
  
  if os.path.isfile(HOSTERY_CONFIG):
    print_color('fatal: Hostery already configured. Edit or delete %s'% HOSTERY_CONFIG, colors.FAIL)
    quit()
  
  # instantiate hostery config

  hostery_config = open(HOSTERY_CONFIG, 'w')
  
  data = Connection.ByType[args.type].GetConfig()
  hostery_config.write(json.dumps(data, indent=2))
  hostery_config.close()
  
  git.ignore(HOSTERY_CONFIG)

  # make empty hostery file on empty hostery branch    
  def txn(branch):
    
    # git ignore everything except hostery file and gitignore.
    command('git rm --cached . -r', verbose=True)
    git_ignore = open('.gitignore', 'w')
    git_ignore.write('*\n!.gitignore\n!%s'%HOSTERY_FILE)
    git_ignore.close()
    git.add('.gitignore')

    # make hostery file
    hostery_file = open(HOSTERY_FILE, 'w')
    hostery_file.write(json.dumps({}))
    hostery_file.close()

    # add, commit, push.
    git.add(HOSTERY_FILE)
    command('git status', multiline=True, verbose=True)
    git.commit('hostery init')
    git.push(branch)

  git.safe_checkout(HOSTERY_BRANCH, txn, empty_branch=True)

  print 'Hostery configured! Use "hostery mark" to upload a commit.'
Ejemplo n.º 2
0
 def GetConfig():
   ignore(GAEConnection.StagingDirectory)
   return { 'type': 'gae', 'root': GAEConnection.StagingDirectory }