Пример #1
0
    def test_changed_files(self):
        with tempfile.TemporaryDirectory() as tmp:
            with utils.ChangeDir(tmp):
                self._setup_git()
                changes = git.changed_files('0000000000000000000000000000000000000000', 'HEAD')
                self.assertEqual(changes, result['first'])

                self._second_commit()
                changes = git.changed_files('HEAD^', 'HEAD')
                self.assertEqual(changes, result['second'])
Пример #2
0
    def test_changed_files(self):
        with tempfile.TemporaryDirectory() as tmp:
            with utils.ChangeDir(tmp):
                self._setup_git()
                changes = git.changed_files(
                    '0000000000000000000000000000000000000000', 'HEAD')
                self.assertEqual(changes, result['first'])

                self._second_commit()
                changes = git.changed_files('HEAD^', 'HEAD')
                self.assertEqual(changes, result['second'])
Пример #3
0
def get_upload_list(commit_number, commit_data, symlink):
  
  files = get_controlled_files()
  
  if len(files) == 0:
    print_color('No files to upload.', colors.FAIL)
    return []

  def make_upload_item(path):
    return UploadItem(path, prefix_dir=commit_number)
  
  upload_list = map(make_upload_item, files)

  prev_commit = get_previous_commit(commit_number, commit_data)

  if not prev_commit or not symlink:
    return upload_list
  
  print_color('Previous marked commit is %s%s'%(colors.OKBLUE, prev_commit), colors.HEADER)
  
  changed_files = git.changed_files(commit_number, prev_commit)
  
  if changed_files == False:
    print_color('Skipping symlink step. Could not read changed files.', colors.WARNING)
    return
  
  def symlink_filter(upload_item):
    if upload_item.path not in changed_files:
      upload_item.set_symlink(prev_commit)
    return upload_item
  
  return map(symlink_filter, upload_list)
Пример #4
0
def main():
    os.umask(settings.UMASK)
    (ref, old, new) = sys.argv[1:4]

    print('starting processing of commit')

    cf = git.changed_files(old, new)

    # do a dry run to catch errors
    for f in cf:
        action = f[4]
        file = f[5]
        obj_id = f[3]

        if file.split('.')[-1] != settings.EXTENSION:
            continue

        if action == 'M' or action == 'A' or action == 'C':
            r = common.process(obj_id, '/dev/null', settings.XSLT)

    # do a real run
    for c in cf:
        action = c[4]
        file = c[5]
        obj_id = c[3]

        if file.split('.')[-1] != settings.EXTENSION:
            continue

        filename = common.xml_filename(file, settings.TARGET)

        if action == 'D':
            print('D {}'.format(file))
            try:
                os.remove(filename)
            except FileNotFoundError:
                print(
                    'file to be removed, but could not be found'.format(file))

        elif action == 'M' or action == 'A' or action == 'C':
            print('C {}'.format(file))
            common.process(obj_id, filename, settings.XSLT)

        else:
            print('unknown git status {} of <{}>'.format(action, file),
                  file=sys.stderr)

    index.update_index(settings.TARGET)
    index.update_json(settings.TARGET)

    print('finished processing of commits')
Пример #5
0
def main():
    os.umask(settings.UMASK)
    (ref,old,new) = sys.argv[1:4]

    print('starting processing of commit')

    cf = git.changed_files(old,new)

    # do a dry run to catch errors
    for f in cf:
        action = f[4]
        file = f[5]
        obj_id = f[3]
        
        if file.split('.')[-1] != settings.EXTENSION:
            continue

        if action == 'M' or action == 'A' or action == 'C':
            r = common.process(obj_id, '/dev/null', settings.XSLT)

    # do a real run
    for c in cf:
        action = c[4]
        file = c[5]
        obj_id = c[3]
        
        if file.split('.')[-1] != settings.EXTENSION:
            continue

        filename = common.xml_filename(file, settings.TARGET)

        if action == 'D':
            print('D {}'.format(file))
            try:
                os.remove(filename)
            except FileNotFoundError:
                print('file to be removed, but could not be found'.format(file))

        elif action == 'M' or action == 'A' or action == 'C':
            print('C {}'.format(file))
            common.process(obj_id, filename, settings.XSLT)

        else:
            print('unknown git status {} of <{}>'.format(action, file), file=sys.stderr)

    index.update_index(settings.TARGET)
    index.update_json(settings.TARGET)

    print('finished processing of commits')