예제 #1
0
def test_020_status(tmpdir, test_paths):
    """Get status info for collection.
    """
    collection = identifier.Identifier(test_paths['TEST_COLLECTION']).object()
    print(collection)
    out = commands.status(collection)
    assert out == EXPECTED_STATUS.strip()
예제 #2
0
def status(collection, log):
    """Report git status of collection repository.
    """
    set_logging(log)
    msg = commands.status(identifier.Identifier(collection).object())
    exit = 0
    click.echo(msg)
예제 #3
0
def merge( request, repo, org, cid ):
    """
    Decides how to merge the various files in a merge conflict.
    Sends user around to different editors and things until everything is merged.
    """
    collection_path = Collection.collection_path(request,repo,org,cid)
    repository = dvcs.repository(collection_path)
    collection = Collection.from_json(collection_path)
    task_id = collection.locked()
    status = commands.status(collection_path)
    ahead = collection.repo_ahead()
    behind = collection.repo_behind()
    diverged = collection.repo_diverged()
    conflicted = collection.repo_conflicted()
    unmerged = dvcs.list_conflicted(repository)
    staged = dvcs.list_staged(repository)
    if request.method == 'POST':
        form = MergeCommitForm(request.POST)
        if form.is_valid():
            which = form.cleaned_data['which']
            if which == 'merge':
                dvcs.merge_commit(repository)
                committed = 1
            elif which == 'commit':
                dvcs.diverge_commit(repository)
                committed = 1
            else:
                committed = 0
            if committed:
                if task_id:
                    collection.unlock(task_id)
                messages.error(request, 'Merge conflict has been resolved. Please sync to make your changes available to other users.')
                return HttpResponseRedirect( reverse('webui-collection', args=[repo,org,cid]) )
            return HttpResponseRedirect( reverse('webui-merge', args=[repo,org,cid]) )
    else:
        which = 'unknown'
        if conflicted and not unmerged:
            which = 'merge'
        elif diverged and staged:
            which = 'commit'
        form = MergeCommitForm({'path':collection_path, 'which':which,})
    return render_to_response(
        'webui/merge/index.html',
        {'repo': repo,
         'org': org,
         'cid': cid,
         'collection_path': collection_path,
         'collection': collection,
         'status': status,
         'conflicted': conflicted,
         'ahead': ahead,
         'behind': behind,
         'unmerged': unmerged,
         'diverged': diverged,
         'staged': staged,
         'form': form,},
        context_instance=RequestContext(request, processors=[])
    )
예제 #4
0
파일: ddr.py 프로젝트: densho/ddr-cmdln
def status(collection, log):
    """Report git status of collection repository.
    """
    set_logging(log)
    msg = commands.status(
        identifier.Identifier(collection).object()
    )
    exit = 0
    click.echo(msg)
예제 #5
0
 def inner(request, *args, **kwargs):
     readable = False
     # if we can get list of collections, storage must be readable
     basepath = settings.MEDIA_BASE
     if not os.path.exists(basepath):
         msg = 'ERROR: Base path does not exist: %s' % basepath
         messages.error(request, msg)
         return HttpResponseRedirect(reverse('storage-required'))
     # realpath(MEDIA_BASE) indicates which Store is mounted
     basepathreal = os.path.realpath(settings.MEDIA_BASE)
     try:
         basepath_listdir = os.listdir(basepath)
     except OSError:
         basepath_listdir = []
     if not basepath_listdir:
         messages.error(request, 'ERROR: Base path exists but is not listable (probably the drive is not mounted).')
         return HttpResponseRedirect(reverse('storage-required'))
     repos_orgs = gitolite.get_repos_orgs()
     if repos_orgs:
         # propagate error
         if (type(repos_orgs) == type('')) and ('error' in repos_orgs):
             messages.error(request, repos_orgs)
             return HttpResponseRedirect(reverse('storage-required'))
         elif (type(repos_orgs) == type([])):
             repo,org = repos_orgs[0].split('-')
             try:
                 collections = models.Collection.collection_paths(settings.MEDIA_BASE, repo, org)
                 readable = True
             except:
                 messages.error(request, 'ERROR: Could not get collections list.')
     else:
         # If there are no repos/orgs, it may mean that the ddr user
         # is missing its SSH keys.
         messages.error(request, STORAGE_MESSAGES['NO_REPOS_ORGS'])
     if not readable:
         logger.debug('storage not readable')
         status,msg = commands.status(basepath)
         logger.debug('storage status: %s' % status)
         logger.debug('storage msg: %s' % msg)
         remount_uri = request.META.get('PATH_INFO',None)
         request.session[settings.REDIRECT_URL_SESSION_KEY] = remount_uri
         if msg == 'unmounted':
             messages.debug(request, '<b>{}</b>: {}'.format(settings.REDIRECT_URL_SESSION_KEY, remount_uri))
             return HttpResponseRedirect(reverse('storage-remount0'))
         else:
             messages.error(request, STORAGE_MESSAGES['ERROR'])
         return HttpResponseRedirect(reverse('storage-required'))
     return func(request, *args, **kwargs)