Esempio n. 1
0
def _update_happened(infofile_filepath, release_notes_dirpath):
  infofile_content = Helper2.assert_jsonfile_exists(infofile_filepath, _default_infofile_content())
  release_notes_files = _release_notes(release_notes_dirpath)
  release_notes_to_display = set(release_notes_files.keys()) - set(infofile_content['release_notes_displayed'])

  h = []
  datestr_format = '%Y%m%d%H%M%S'
  for datestr in release_notes_to_display:
    heapq.heappush(h, datetime.datetime.strptime(datestr, datestr_format))

  newly_displayed = []
  for i in range(len(h)):
    datestr = heapq.heappop(h).strftime(datestr_format)
    filepath_to_display = release_notes_files.get(datestr)
    if filepath_to_display is not None:
      newly_displayed.append(datestr)
      with open(filepath_to_display) as file:
        print "--------------------------- %s ---------------------------" % filepath_to_display
        print file.read()

  if len(newly_displayed) > 0:
    infofile_content['release_notes_displayed'].extend(newly_displayed)
    Helper2.write_dict_to_file(infofile_filepath, infofile_content)
Esempio n. 2
0
def update(repo_path,
  force = False,
  branch = 'master',
  infofile_filepath = Helper2.get_data_filepath('infofile'),
  release_notes_dirpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'release_notes')):

  helper = Helper2(repo_path = repo_path)
  remote_sha = helper.remote_head_sha(dst_branch = branch)
  local_sha = helper.local_sha(branch = branch)

  if remote_sha == local_sha:
    print "Up to date"
  else:
    if helper.uncommited_changes():
      print "An update is available but there are uncommited changes in " + repo_path
      sys.exit(-1)

    if force or _prompt("An update is available. Update now?"):
      helper.checkout(branch)
      helper.merge(remote_sha)
      _update_happened(infofile_filepath, release_notes_dirpath)
      print "Updated"
Esempio n. 3
0
def <name>(args):
  git_scripts_repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
  branch = Helper2(git_scripts_repo_path).current_branch()
  print("It works! Your local git-scripts repo is in branch '{0}'".format(branch))
  print("Run `python -m unittest test.{0}` to run the test".format('<name>'))
  return True