[Python-modules-commits] [python-modules] 01/02: make-mrconfig: port to python3 and salsa.d.o
Sandro Tosi
morph at moszumanska.debian.org
Sun Mar 25 01:55:55 UTC 2018
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository python-modules.
commit 273c7bf336238df30a1f5e726525ab6e17e2e198
Author: Sandro Tosi <morph at debian.org>
Date: Sat Mar 24 21:47:41 2018 -0400
make-mrconfig: port to python3 and salsa.d.o
---
make-mrconfig | 91 ++++++++++++++++++++---------------------------------------
1 file changed, 30 insertions(+), 61 deletions(-)
diff --git a/make-mrconfig b/make-mrconfig
index 149a55f..cd56443 100755
--- a/make-mrconfig
+++ b/make-mrconfig
@@ -1,75 +1,44 @@
-#!/bin/bash
-set -e
+#!/usr/bin/python3
-# Weakly adapted from
-# https://anonscm.debian.org/cgit/pkg-ruby-extras/pkg-ruby-extras.git/tree/make-mrconfig
-# Which was strongly adapted from
-# http://svn.debian.org/viewsvn/pkg-ocaml-maint/trunk/projects/git-guide/d-o-m-mrconfig.sh
+import requests
+import os
-function msg() {
- echo "I: $1"
-}
+OUTFILE='.mrconfig'
+# 2781 is the group_id for python-team/modules subgroup, it could be automatically obtained
+# from https://salsa.debian.org/api/v4/groups/python-team/subgroups/ but meh
+URL="https://salsa.debian.org/api/v4/groups/2781"
-function output() {
- echo "$1" >> $OUTPUT
-}
-
-msg "Setting up output file"
-OUTPUT="$1"
-if [ -z "$OUTPUT" ] ; then
- OUTPUT=".mrconfig"
-fi
-
-msg "Retrieving package list"
-
-# Packages hosted in Git
-GIT_REPODIR="/git/python-modules/packages/"
-GIT_PKGS=`ssh git.debian.org "(cd $GIT_REPODIR && LC_ALL=C ls -1d *.git)" | sed '/python-modules.git/d; s/.git$//' | LC_ALL=C sort`
-
-msg "Generating mrconfig file in $OUTPUT"
-
-# Backup the output file if it exists
-if [ -f $OUTPUT ]; then
- mv $OUTPUT ${OUTPUT}\~
-fi
-
-# Setting up mr lib
-output "[DEFAULT]
+FILEHEADER="""[DEFAULT]
lib=
msg () {
- echo \"I: \$1\"
+ echo \"I: $1\"
}
git_checkout () {
- git clone git+ssh://git.debian.org$GIT_REPODIR\$1.git &&
- cd \$1 &&
+ git clone git at salsa.debian.org:python-team/modules/$1.git &&
+ cd $1 &&
{ git branch --track upstream remotes/origin/upstream || true; } &&
{ git branch --track pristine-tar remotes/origin/pristine-tar || true; } &&
{ (echo \"[DEFAULT]\"; echo \"pristine-tar = True\") > .git/gbp.conf; } &&
- { test -z \"\$DEBFULLNAME\" || git config user.name \"\$DEBFULLNAME\" || true; } &&
- { test -z \"\$DEBEMAIL\" || git config user.email \"\$DEBEMAIL\" || true; }
+ { test -z \"$DEBFULLNAME\" || git config user.name \"$DEBFULLNAME\" || true; } &&
+ { test -z \"$DEBEMAIL\" || git config user.email \"$DEBEMAIL\" || true; }
}
-"
-
-# Sections for Git repositories
-for i in $GIT_PKGS; do
- output "[$i]
-checkout = git_checkout $i
+"""
+REPOTEMPLATE="""
+[%s]
+checkout = git_checkout %s
skip = lazy
-"
-done
+"""
+
+
+print("Retrieving package list")
+
+data = requests.get(URL).json()
+
+print("Updating .mrconfig")
-# Warn if changes have been made
-if which colordiff >/dev/null; then
- diff=colordiff
-else
- diff=diff
-fi
-if [ -f ${OUTPUT}\~ ] && $diff -u ${OUTPUT}\~ ${OUTPUT}; then
- rm ${OUTPUT}\~
- msg "no changes"
-else
- msg "$OUTPUT changed!"
-fi
+with open(OUTFILE, 'w') as f:
+ f.write(FILEHEADER)
+ for project in sorted([x['name'] for x in data['projects']]):
+ f.write(REPOTEMPLATE % (project, project))
-# Finish
-msg "all done, enjoy: mr [checkout,update,...]"
+os.system('git diff %s' % OUTFILE)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/tools/python-modules.git
More information about the Python-modules-commits
mailing list