]> git.ozlabs.org Git - next-scripts/commitdiff
add_repo: improve it add all the bits
authorStephen Rothwell <sfr@canb.auug.org.au>
Mon, 8 Sep 2025 22:20:45 +0000 (08:20 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 8 Sep 2025 22:20:45 +0000 (08:20 +1000)
add_repo

index f97551efe311e9524d4ad945e547271f47d8bdd2..906c4053cb2b5e0f86f4ba56cdd2d4680c088011 100755 (executable)
--- a/add_repo
+++ b/add_repo
@@ -1,14 +1,19 @@
 #!/bin/sh
 
-if [ $# -lt 2 ] || [ $# -gt 3 ]; then
-       printf 'usage: %s <remote name> <url> [<branch>]\n' "$0" 1>&2
+if [ $# -lt 3 ] || [ $# -gt 4 ]; then
+       printf 'usage: %s <contacts> <remote name> <url> [<branch>]\n' "$0" 1>&2
        exit 1
 fi
 
-name="$1"
-url="$2"
-branch="$3"
+contacts="$1"
+name="$2"
+url="$3"
+branch="$4"
 
+if [ -z "$contacts" ]; then
+       printf 'Need contacts\n' 1>&2
+       exit 1
+fi
 if [ -z "$name" ]; then
        printf 'Need a remote name\n' 1>&2
        exit 1
@@ -21,8 +26,26 @@ if [ -z "$branch" ]; then
        branch='master'
 fi
 
-if git remote add --no-tags -t "$branch" "$name" "$url"; then
-       cp .git/config ../etc/git-config
+url=$(printf '%s\n' "$url" | sed -Ee '
+       s,^(git|https)://git.kernel.org/pub/scm/linux/kernel/git/,korg:,
+       s,^(git|https)://git.kernel.org/pub/scm/fs/,korgfs:,
+       s,^git://git.infradead.org/,id:,
+       s,^https://github.com/,gh:,
+       s,^https://gitlab.freedesktop.org/,gfo:,
+       s,/$,,')
+
+if ! git remote add --no-tags -t "$branch" "$name" "$url"; then
+       exit 1
 fi
 
+cp .git/config ../etc/git-config
+
+cd ../etc/
+
+printf '%s\tgit\t%s\t-\t%s\tno\n' "$contacts" "$name" "$branch" >>../etc/control
+
+git diff
+
+printf '\nYou should probably adjust where this tree is listed in the control file\n'
+
 exit 0