diff --git a/.arcconfig b/.arcconfig new file mode 100644 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,3 @@ +{ + "phabricator.uri" : "https://phabricator.kde.org/" +} diff --git a/helpers/sync-staging.sh b/helpers/sync-staging.sh new file mode 100644 --- /dev/null +++ b/helpers/sync-staging.sh @@ -0,0 +1,11 @@ +# Static Config +mgmtdir="/home/git/repo-management" + +# Grab our input +reponame="$1" + +# Build the remote URL up +remoteurl="staging@code.kde.org:$reponame" +# Now we push it up there +cd "/srv/git/repositories/$reponame" +python $mgmtdir/helpers/update-repo-mirror.py "$reponame" "$remoteurl" diff --git a/hooks/post-update b/hooks/post-update --- a/hooks/post-update +++ b/hooks/post-update @@ -15,6 +15,9 @@ # Initiate propagator-agent equipped anongit mirror updates and suppress output nohup bash $mgmtdir/helpers/sync-to-elder.sh "${reponame}.git" < /dev/null &> /dev/null &! +# Trigger staging update +nohup bash $mgmtdir/helpers/sync-staging.sh "${reponame}.git" < /dev/null &> /dev/null &! + # Trigger Github update # Only mainline repositories are to be mirrored - no scratch, clones, websites or sysadmin repos if [[ $urlpath != *"/"* ]] && [[ $urlpath != "gitolite-admin.git" ]]; then diff --git a/hooks/update.secondary.staging b/hooks/update.secondary.staging new file mode 100755 --- /dev/null +++ b/hooks/update.secondary.staging @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +# Load dependencies +import os +import re +import sys +import subprocess +from hooklib import Repository, Commit, CommitAuditor, CommitNotifier, MessageBuilder, CommitChecker, CiaNotifier, RepoType, ChangeType, RefType + +def usage(): + print "Information needed to run could not be gathered successfully." + print "Required environment variables: GIT_DIR, GL_USER, HOME" + print "Syntax: update.secondary " + exit(1) + +def maintenance(): + print "Sorry, but the repository you are trying to access is currently unavailable." + print "This is to allow for maintenance, we apologise for any inconvience caused." + print "If you believe this not to be the case, please contact sysadmin@kde.org." + exit(1) + +##### +# Initialisation +##### + +# Read arguments... +try: + ref_name = sys.argv[1] + old_sha1 = sys.argv[2] + new_sha1 = sys.argv[3] +except IndexError: + usage() + +# Read needed environment variables +git_dir = os.getenv('GIT_DIR') +push_user = os.getenv('GL_USER') +user_home = os.getenv('HOME') + +# Check for maintenance mode... +if os.path.exists(user_home + "/.gitolite.down") or os.path.exists(git_dir + "/.gitolite.down"): + maintenance() + +# Initialise the repository +Repository.BaseDir = "/srv/staging/repositories/" + +repository = Repository( ref_name, old_sha1, new_sha1, push_user ) + +##### +# Auditing +##### + +# Repository change checks... +if push_user != 'scmsync' and repository.ref_type is not RefType.Tag and not re.match("^phabricator/(.+)/(.+)", repository.ref_name): + print "Pushing to staging repository manually is disabled" + print "Push declined" + exit(1) + +# should we do audit in staging repos? I'd say yes because it makes automatic landing not fail +auditor = CommitAuditor( repository ) +audit_base = repository.management_directory + "/repo-configs/audit/" +if auditedRef and not os.path.exists(audit_base + repository.path + ".git/skip-eol"): + auditor.audit_eol() + +if auditedRef and not os.path.exists(audit_base + repository.path + ".git/skip-filename"): + auditor.audit_filename() + +if auditedRef and not os.path.exists(audit_base + repository.path + ".git/skip-author-names"): + auditor.audit_names_in_metadata() + +if auditedRef and not os.path.exists(audit_base + repository.path + ".git/skip-author-emails"): + auditor.audit_emails_in_metadata() + +blocked_path = repository.management_directory + "/repo-configs/blocked/" + repository.path +if auditedRef and os.path.exists(blocked_path): + auditor.audit_hashes(blocked_path) + +# Did we have any commit audit failures? +if auditor.audit_failed: + print "Push declined - commits failed audit" + exit(1) + +# Everything is done.... +exit(0)