# Syntax:
# This file is read in order; later entries that match a package win.

# Each "policy" stanza can contain a number of settings and a set of
# matches that determine what packages the policy applies to.
# All conditions in a match must be met. A match can check for:
#
# * uploader: E-mail appears in Uploaders field.
# * maintainer: E-mail matches Maintainer field email.
# * source_package: Name matches Source package name
# * in_base: Does the package appear in the base distribution
# * before_stage: whether a release stage has not yet been entered

# Support modes:
#  build_only: Build the package, but don't do anything with it
#  push: Push the changes to the packaging branch
#  propose: Create a merge proposal with the changes
#  bts: Create and maintain a patch in the BTS
#  attempt_push: Push the changes to the packaging branch;
#     if the janitor doesn't have permission to push, create a merge proposal
#     instead.

# URL to load freeze information from.
freeze_dates_url: "https://release.debian.org/testing/freeze-and-release-dates.yaml"

# Default behaviour
policy {
  # Note that there's no match stanza here so policy here applies to all
  # packages.

  # Fixing lintian issues
  campaign {
    name: "lintian-fixes"
    command: "lintian-brush"
    publish { mode: propose }
    qa_review: required;
  }

  # Don't propose merges for upstream merges for now, since the janitor only
  # proposes changes to the main branch, not to pristine-tar/upstream.
  # See https://salsa.debian.org/jelmer/janitor/issues/18
  campaign {
    name: "fresh-releases"
    command: "new-upstream"
    publish { mode: build_only }
    qa_review: required;
  }

  campaign {
    name: "fresh-snapshots"
    publish { mode: build_only }
    command: "new-upstream --snapshot"
    qa_review: required;
  }

  # Builds of packaging repositories without any changes applied.
  # These are used as base when generating debdiffs and diffoscope diffs.
  campaign {
    name: "unchanged"
    publish { mode: build_only }
    command: "true"
    qa_review: required;
  }

  # Apply multi-arch changes (apply-multiarch-hints)
  campaign {
    name: "multiarch-fixes"
    publish { mode: propose }
    command: "apply-multiarch-hints"
    qa_review: required;
  }

  # Mark orphaned packages as orphaned, updating Vcs-Git headers and Maintainer
  # field.
  campaign {
    name: "orphan"
    publish { mode: build_only }
    command: "orphan --no-update-vcs"
    qa_review: required;
  }

  # Drop people who are MIA from uploader fields
  campaign {
    name: "mia"
    publish { mode: attempt_push }
    command: "mia"
    qa_review: required;
  }

  # Import NMU changes
  suite: {
    name: "uncommitted"
    publish { mode: build_only }
    command: "deb-import-uncommitted"
    qa_review: required;
  }

  # CME fixes, for testing purposes.
  campaign {
    name: "cme"
    publish { mode: build_only }
    command: "cme-fix"
    qa_review: required;
  }

  # Remove obsolete dependencies and other settings.
  campaign {
    name: "scrub-obsolete"
    publish { mode: propose }
    command: "scrub-obsolete"
    qa_review: required;
  }

  # Generating Debian packaging from scratch
  campaign {
    name: "debianize"
    publish { mode: build_only }
    command: "debianize"
    qa_review: required;
  }

  campaign {
    name: "upstream-unchanged"
    publish { mode: build_only }
    command: "true"
    qa_review: required;
  }

  # Possible changelog types: auto, update, leave
  #
  # Auto means that the changelog will be updated by default, unless
  # some indicator is found that gbp-dch is used with the package
  # (e.g. a [dch] section in debian/gbp.conf)
  env {
    name: "DEB_UPDATE_CHANGELOG"
    value: "auto"
  }
}

policy {
  match { vcs_url_regex: "https:\/\/salsa\.debian\.org\/debian\/.*" }
  # Mark orphaned packages as orphaned, updating Vcs-Git headers and Maintainer
  # field.
  campaign {
    name: "orphan"
    publish { mode: attempt_push }
  }
}

# Make sure we don't accidentally push to unsuspecting
# collab-maint repositories, even if debian-janitor becomes a
# member of "debian" in the future.
policy {
  match { vcs_url_regex: "https:\/\/salsa\.debian\.org\/debian\/.*" }

  campaign {
    name: "multiarch-fixes"
    publish { mode: propose }
  }

  campaign {
    name: "lintian-fixes"
    publish { mode: propose }
  }
}

# Don't upgrade exabgp packages beyond oldstable.
policy {
  match { source_package: "exabgp" }

  campaign {
    name: "lintian-fixes"
    command: "lintian-brush --compat-release=oldstable"
  }
}
