Esempio n. 1
0
def run(dry_run):
    default_days_interval = 15
    default_limit = 8
    default_enable_closing = False
    instance = queries.get_gitlab_instance()
    settings = queries.get_app_interface_settings()
    repos = queries.get_repos_gitlab_housekeeping(server=instance['url'])

    for repo in repos:
        hk = repo['housekeeping']
        project_url = repo['url']
        days_interval = hk.get('days_interval') or default_days_interval
        enable_closing = hk.get('enable_closing') or default_enable_closing
        limit = hk.get('limit') or default_limit
        gl = GitLabApi(instance, project_url=project_url, settings=settings)
        handle_stale_items(dry_run, gl, days_interval, enable_closing, 'issue')
        handle_stale_items(dry_run, gl, days_interval, enable_closing,
                           'merge-request')
        rebase = hk.get('rebase')
        try:
            merge_merge_requests(dry_run, gl, limit, rebase, insist=True)
        except Exception:
            merge_merge_requests(dry_run, gl, limit, rebase)
        if rebase:
            rebase_merge_requests(dry_run, gl, limit)
Esempio n. 2
0
def run(dry_run, wait_for_pipeline):
    default_days_interval = 15
    default_limit = 8
    default_enable_closing = False
    instance = queries.get_gitlab_instance()
    settings = queries.get_app_interface_settings()
    repos = queries.get_repos_gitlab_housekeeping(server=instance["url"])

    for repo in repos:
        hk = repo["housekeeping"]
        project_url = repo["url"]
        days_interval = hk.get("days_interval") or default_days_interval
        enable_closing = hk.get("enable_closing") or default_enable_closing
        limit = hk.get("limit") or default_limit
        pipeline_timeout = hk.get("pipeline_timeout")
        gl = GitLabApi(instance, project_url=project_url, settings=settings)

        handle_stale_items(dry_run, gl, days_interval, enable_closing, "issue")
        handle_stale_items(dry_run, gl, days_interval, enable_closing,
                           "merge-request")
        rebase = hk.get("rebase")
        try:
            merge_merge_requests(
                dry_run,
                gl,
                limit,
                rebase,
                pipeline_timeout,
                insist=True,
                wait_for_pipeline=wait_for_pipeline,
                gl_instance=instance,
                gl_settings=settings,
            )
        except Exception:
            merge_merge_requests(
                dry_run,
                gl,
                limit,
                rebase,
                pipeline_timeout,
                wait_for_pipeline=wait_for_pipeline,
                gl_instance=instance,
                gl_settings=settings,
            )
        if rebase:
            rebase_merge_requests(
                dry_run,
                gl,
                limit,
                pipeline_timeout=pipeline_timeout,
                wait_for_pipeline=wait_for_pipeline,
                gl_instance=instance,
                gl_settings=settings,
            )
Esempio n. 3
0
def run(dry_run=False, days_interval=15, enable_closing=False, limit=1):
    instance = queries.get_gitlab_instance()
    settings = queries.get_app_interface_settings()
    repos = queries.get_repos_gitlab_housekeeping(server=instance['url'])

    for repo in repos:
        project_url = repo['url']
        gl = GitLabApi(instance, project_url=project_url, settings=settings)
        handle_stale_items(dry_run, gl, days_interval, enable_closing, 'issue')
        handle_stale_items(dry_run, gl, days_interval, enable_closing,
                           'merge-request')
        merge_merge_requests(dry_run, gl, limit)
        if repo['enable_rebase']:
            rebase_merge_requests(dry_run, gl, limit)