Ejemplo n.º 1
0
def sync_resources(db_project, now, force, no_pull):
    # Pull source repository
    if no_pull:
        source_repo_changed = True  # Assume changed
    else:
        source_repo_changed = pull_changes(db_project, source_only=True)

    # If the only repo hasn't changed since the last sync and there are
    # no Pontoon-side changes for this project, quit early.
    if not force and not db_project.needs_sync and not source_repo_changed and db_project.has_single_repo:
        log.info('Skipping project {0}, no changes detected.'.format(db_project.slug))
        return False

    if force or source_repo_changed:
        try:
            project_changes, obsolete_vcs_resources, new_paths = update_originals(db_project, now, full_scan=force)
        except MissingSourceDirectoryError as e:
            log.error(e)
            return False

        if not db_project.has_single_repo:
            db_project.source_repository.set_last_synced_revisions()
        log.info('Synced resources for project {0}.'.format(db_project.slug))

    else:
        project_changes, obsolete_vcs_resources, new_paths = None, None, None
        log.info('Skipping syncing resources for project {0}, no changes detected.'.format(db_project.slug))

    return {
        'project_changes': project_changes,
        'obsolete_vcs_resources': obsolete_vcs_resources,
        'new_paths': new_paths,
    }
Ejemplo n.º 2
0
def sync_resources(db_project, now, force, no_pull):
    # Pull source repository
    if no_pull:
        source_repo_changed = True  # Assume changed
    else:
        source_repo_changed, _ = pull_changes(db_project, source_only=True)

    # If the only repo hasn't changed since the last sync and there are
    # no Pontoon-side changes for this project, quit early.
    if not force and not db_project.needs_sync and not source_repo_changed and db_project.has_single_repo:
        log.info('Skipping project {0}, no changes detected.'.format(db_project.slug))
        return False

    if force or source_repo_changed:
        try:
            project_changes, obsolete_vcs_resources, new_paths = update_originals(db_project, now, full_scan=force)
        except MissingSourceDirectoryError as e:
            log.error(e)
            return False

        if not db_project.has_single_repo:
            db_project.source_repository.set_last_synced_revisions()
        log.info('Synced resources for project {0}.'.format(db_project.slug))

    else:
        project_changes, obsolete_vcs_resources, new_paths = None, None, None
        log.info('Skipping syncing resources for project {0}, no changes detected.'.format(db_project.slug))

    return {
        'project_changes': project_changes,
        'obsolete_vcs_resources': obsolete_vcs_resources,
        'new_paths': new_paths,
    }
Ejemplo n.º 3
0
def sync_sources(db_project, now, force, no_pull):
    # Pull from source repository
    if no_pull:
        has_source_repo_changed = True
    else:
        log.info(
            "Pulling source changes for project {0} started.".format(db_project.slug)
        )
        has_source_repo_changed = pull_source_repo_changes(db_project)
        log.info(
            "Pulling source changes for project {0} complete.".format(db_project.slug)
        )

    # If the only repo hasn't changed since the last sync and there are
    # no Pontoon-side changes for this project, quit early.
    if (
        not force
        and not db_project.needs_sync
        and not has_source_repo_changed
        and db_project.has_single_repo
    ):
        log.info("Skipping project {0}, no changes detected.".format(db_project.slug))
        return False

    if force or has_source_repo_changed:
        try:
            added_paths, removed_paths, changed_paths, new_entities = update_originals(
                db_project, now, force=force
            )
        except MissingSourceDirectoryError as e:
            log.error(e)
            return False

        log.info("Synced sources for project {0}.".format(db_project.slug))

    else:
        added_paths, removed_paths, changed_paths, new_entities = None, None, None, None
        log.info(
            "Skipping syncing sources for project {0}, no changes detected.".format(
                db_project.slug
            )
        )

    return {
        "has_source_repo_changed": has_source_repo_changed,
        "added_paths": added_paths,
        "removed_paths": removed_paths,
        "changed_paths": changed_paths,
        "new_entities": new_entities,
    }
Ejemplo n.º 4
0
def sync_sources(db_project, now, force, no_pull):
    # Pull source repository
    if no_pull:
        source_repo_changed = True  # Assume changed
    else:
        source_repo_changed, _ = pull_changes(db_project)

    # If the only repo hasn't changed since the last sync and there are
    # no Pontoon-side changes for this project, quit early.
    if (
        not force
        and not db_project.needs_sync
        and not source_repo_changed
        and db_project.has_single_repo
    ):
        log.info("Skipping project {0}, no changes detected.".format(db_project.slug))
        return False

    if force or source_repo_changed:
        try:
            added_paths, removed_paths, changed_paths, new_entities = update_originals(
                db_project, now, full_scan=force
            )
        except MissingSourceDirectoryError as e:
            log.error(e)
            return False

        if not db_project.has_single_repo:
            db_project.source_repository.set_last_synced_revisions()
        log.info("Synced sources for project {0}.".format(db_project.slug))

    else:
        added_paths, removed_paths, changed_paths, new_entities = None, None, None, None
        log.info(
            "Skipping syncing sources for project {0}, no changes detected.".format(
                db_project.slug
            )
        )

    return {
        "added_paths": added_paths,
        "removed_paths": removed_paths,
        "changed_paths": changed_paths,
        "new_entities": new_entities,
    }