Beispiel #1
0
def test_remotes():
    path_orig = os.path.join(TESTING_BASE_DIR, 'testrepo1')
    path_clon = os.path.join(TESTING_BASE_DIR, 'clone')
    # rm existing
    if os.path.exists(path_orig):
        shutil.rmtree(path_orig)
    if os.path.exists(path_clon):
        shutil.rmtree(path_clon)
    # set up repos
    repo1 = make_repo(path_orig, ['testing'])
    clone = clone_repo(repo1, path_clon)
    # clone lists origin in remotes, origin doesn't know the clone
    expected1 = []
    expected2 = [
        {
            'name': 'origin',
            'url': os.path.join(path_orig, '.git'),
            'target': os.path.join(path_orig, '.git'),
            'fetch': '+refs/heads/*:refs/remotes/origin/*',
            'clone': 1,
            'local': 1,
            'local_exists': 1,
        }
    ]
    # test
    out1 = dvcs.remotes(repo1)
    out2 = dvcs.remotes(clone)
    assert out1 == expected1
    assert out2 == expected2
Beispiel #2
0
def test_remotes(tmpdir):
    path_orig = str(tmpdir / 'testrepo1')
    path_clon = str(tmpdir / 'clone')
    # rm existing
    if os.path.exists(path_orig):
        shutil.rmtree(path_orig)
    if os.path.exists(path_clon):
        shutil.rmtree(path_clon)
    # set up repos
    repo1 = make_repo(path_orig, ['testing'])
    clone = clone_repo(repo1, path_clon)
    # clone lists origin in remotes, origin doesn't know the clone
    expected1 = []
    expected2 = [{
        'name': 'origin',
        'url': os.path.join(path_orig, '.git'),
        'target': os.path.join(path_orig, '.git'),
        'fetch': '+refs/heads/*:refs/remotes/origin/*',
        'clone': 1,
        'local': 1,
        'local_exists': 1,
    }]
    # test
    out1 = dvcs.remotes(repo1)
    out2 = dvcs.remotes(clone)
    assert out1 == expected1
    assert out2 == expected2
Beispiel #3
0
def git_status( request, cid ):
    collection = Collection.from_identifier(Identifier(cid))
    alert_if_conflicted(request, collection)
    gitstatus = collection.gitstatus()
    remotes = dvcs.remotes(dvcs.repository(collection.path))
    return render(request, 'webui/collections/git-status.html', {
        'collection': collection,
        'status': gitstatus.get('status', 'git-status unavailable'),
        'astatus': gitstatus.get('annex_status', 'annex-status unavailable'),
        'timestamp': gitstatus.get('timestamp'),
        'remotes': remotes,
    })
Beispiel #4
0
def sync(user_name, user_mail, collection_path):
    """Sync repo with bare clone on hub server; use instead of git-annex-sync.
    
    Git-annex has a "sync" command for communicating annex changes between
    repositories, but it is designed to be used between non-bare repositories.
    Normally Git does not support pushing to non-bare repositories, and
    git-annex does some trickery involving "synced/BRANCH" branches to make
    this work.
    Reference: http://git-annex.branchable.com/sync/
    
    When git-annex-sync is used between a non-bare repo and a bare repo
    (e.g. between a local repo and our hub server running Gitolite),
    the "synced/master" branches do not get merged in to master and syncing
    no longer works.  Therefore it is necessary to sync manually.
    
    If you think you want to use git-annex-sync, remember that we tried this
    in commit 1857a7aa3f and it did not work and we reverted to manual syncing.
    
    @param user_name: Username for use in changelog, git log
    @param user_mail: User email address for use in changelog, git log
    @param collection_path: Absolute path to collection repo.
    @return: message ('ok' if successful)
    """
    collection = DDRCollection(collection_path)
    repo = dvcs.repository(collection.path, user_name, user_mail)
    logging.debug('repo: %s' % repo)
    dvcs.set_annex_description(repo)
    if not GIT_REMOTE_NAME in [r.name for r in repo.remotes]:
        repo.create_remote(GIT_REMOTE_NAME, collection.git_url)
    # list remotes
    logging.debug('remotes')
    for remote in dvcs.remotes(collection_path):
        logging.debug('- %s %s' % (remote['name'], remote['url']))
    # pull
    logging.debug('git pull %s master' % GIT_REMOTE_NAME)
    repo.git.checkout('master')
    repo.git.pull(GIT_REMOTE_NAME, 'master')
    logging.debug('git pull %s git-annex' % GIT_REMOTE_NAME)
    repo.git.checkout('git-annex')
    repo.git.pull(GIT_REMOTE_NAME, 'git-annex')
    #logging.debug('OK')
    # push
    logging.debug('git pull %s git-annex' % GIT_REMOTE_NAME)
    repo.git.checkout('git-annex')
    repo.git.push(GIT_REMOTE_NAME, 'git-annex')
    logging.debug('git pull %s master' % GIT_REMOTE_NAME)
    repo.git.checkout('master')
    repo.git.push(GIT_REMOTE_NAME, 'master')
    logging.debug('OK')
    return 0,'ok'
Beispiel #5
0
def git_status( request, repo, org, cid ):
    collection = Collection.from_request(request)
    alert_if_conflicted(request, collection)
    gitstatus = collection.gitstatus()
    remotes = dvcs.remotes(dvcs.repository(collection.path))
    return render_to_response(
        'webui/collections/git-status.html',
        {'collection': collection,
         'status': gitstatus.get('status', 'git-status unavailable'),
         'astatus': gitstatus.get('annex_status', 'annex-status unavailable'),
         'timestamp': gitstatus.get('timestamp'),
         'remotes': remotes,
         },
        context_instance=RequestContext(request, processors=[])
    )
Beispiel #6
0
def sync(user_name, user_mail, collection):
    """Sync repo with bare clone on hub server; replaces git-annex-sync.
    
    Git-annex has a "sync" command for communicating annex changes between
    repositories, but it is designed to be used between non-bare repositories.
    Normally Git does not support pushing to non-bare repositories, and
    git-annex does some trickery involving "synced/BRANCH" branches to make
    this work.
    Reference: http://git-annex.branchable.com/sync/
    
    When git-annex-sync is used between a non-bare repo and a bare repo
    (e.g. between a local repo and our hub server running Gitolite),
    the "synced/master" branches do not get merged in to master and syncing
    no longer works.  Therefore it is necessary to sync manually.
    
    If you think you want to use git-annex-sync, remember that we tried this
    in commit 1857a7aa3f and it did not work and we reverted to manual syncing.
    
    @param user_name: Username for use in changelog, git log
    @param user_mail: User email address for use in changelog, git log
    @param collection: Collection
    @return: message ('ok' if successful)
    """
    repo = dvcs.repository(collection.path, user_name, user_mail)
    logging.debug('repo: %s' % repo)
    drive_label = storage.drive_label(repo.working_dir)
    dvcs.annex_set_description(repo,
                               dvcs.annex_status(repo),
                               drive_label=drive_label)
    dvcs.remote_add(repo, collection.git_url, config.GIT_REMOTE_NAME)
    # list remotes
    logging.debug('remotes')
    for remote in dvcs.remotes(repo):
        logging.debug('- %s %s' % (remote['name'], remote['target']))
    # sync
    logging.debug('git annex sync')
    out = repo.git.annex('sync')
    logging.debug(out)
    return 0, 'ok'
Beispiel #7
0
def sync(user_name, user_mail, collection):
    """Sync repo with bare clone on hub server; replaces git-annex-sync.
    
    Git-annex has a "sync" command for communicating annex changes between
    repositories, but it is designed to be used between non-bare repositories.
    Normally Git does not support pushing to non-bare repositories, and
    git-annex does some trickery involving "synced/BRANCH" branches to make
    this work.
    Reference: http://git-annex.branchable.com/sync/
    
    When git-annex-sync is used between a non-bare repo and a bare repo
    (e.g. between a local repo and our hub server running Gitolite),
    the "synced/master" branches do not get merged in to master and syncing
    no longer works.  Therefore it is necessary to sync manually.
    
    If you think you want to use git-annex-sync, remember that we tried this
    in commit 1857a7aa3f and it did not work and we reverted to manual syncing.
    
    @param user_name: Username for use in changelog, git log
    @param user_mail: User email address for use in changelog, git log
    @param collection: Collection
    @return: message ('ok' if successful)
    """
    repo = dvcs.repository(collection.path, user_name, user_mail)
    logging.debug('repo: %s' % repo)
    drive_label = storage.drive_label(repo.working_dir)
    dvcs.annex_set_description(repo, dvcs.annex_status(repo), drive_label=drive_label)
    dvcs.remote_add(repo, collection.git_url, config.GIT_REMOTE_NAME)
    # list remotes
    logging.debug('remotes')
    for remote in dvcs.remotes(repo):
        logging.debug('- %s %s' % (remote['name'], remote['target']))
    # sync
    logging.debug('git annex sync')
    out = repo.git.annex('sync')
    logging.debug(out)
    return 0,'ok'