Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160734387
D24231.id70642.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D24231.id70642.diff
View Options
Index: Mk/Scripts/print-submodule-gh_tuple.sh
===================================================================
--- Mk/Scripts/print-submodule-gh_tuple.sh
+++ Mk/Scripts/print-submodule-gh_tuple.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+# print GH_TUPLE with all git submodules
+#
+# Feature: print-gh-tuple
+# Usage: make print-gh-tuple
+# Valid ARGS: git-repository-path (path of git directory cloned with submodules hierarchically)
+#
+# MAINTAINER: yuri@FreeBSD.org
+
+# CAVEATS:
+# * Does not handle GitHub project redirects
+# * Does not handle GitHub project case mismatches
+# * Does not handle non-GitHub git modules
+
+if [ -z "$1" ] || ! [ -d $1/.git ];
+then
+ echo >&2 "Usage: $0 {cloned-git-repository}"
+ exit 1
+fi
+
+cd $1
+
+for gitmodules_file in $(find . -name .gitmodules);
+do
+ echo "dir $(dirname $gitmodules_file)"
+ git config --file $gitmodules_file -l | sed -E 's/^submodule\.([A-Za-z0-9\._\/\-]*)\.(.*)=(.*)/submodule \1 \2 \3/'
+ (cd $(dirname $gitmodules_file) && git submodule status) | sed -e 's/^/hash /'
+done | awk '
+ BEGIN {
+ num_keys = 0
+ }
+ /dir/ {
+ dir = $2
+ if (dir == ".")
+ dir = ""
+ else {
+ sub("^./", "", dir)
+ dir = dir "/"
+ }
+ }
+ /submodule/ {
+ key = dir "/" $2
+ if ($3 == "path") {
+ map_module_path[key] = $4
+ all_keys[num_keys++] = key
+ } else if ($3 == "url") {
+ map_module_url[key] = $4
+ }
+ map_module_dir[key] = dir
+ }
+ /hash/ {
+ map_module_hash[dir "/" $3]=$2
+ }
+ END {
+ print "GH_TUPLE= \\"
+ idx = 0
+ key = ""
+ for (i = 0; i < num_keys; i++) {
+ key_prev = key
+ key = all_keys[i]
+ url = map_module_url[key]
+ if (match(url, /^(https|git):\/\/github\.com\//)) {
+ gh_account_user = url
+ sub("^(https|git)://github\.com/", "", gh_account_user)
+ sub("(.git|/)$", "", gh_account_user)
+ sub("/", ":", gh_account_user)
+ id = gh_account_user
+ gsub("[:-]", "_", id)
+ if (idx > 0 && map_module_dir[key] != map_module_dir[key_prev])
+ print " \\"
+ print " " gh_account_user ":" map_module_hash[map_module_dir[key] "/" map_module_path[key]] ":" id "/" map_module_dir[key] map_module_path[key] " \\"
+ id_uniq[id]++
+ idx++
+ }
+ }
+
+ for (i = 0; i < num_keys; i++) {
+ key = all_keys[i]
+ if (!match(map_module_url[key], /^(https|git):\/\/github\.com\//))
+ print "# not a GitHub URL: " map_module_url[key] " " map_module_hash[key] " " map_module_dir[key] " " map_module_path[key]
+ }
+ }
+'
Index: Mk/bsd.sites.mk
===================================================================
--- Mk/bsd.sites.mk
+++ Mk/bsd.sites.mk
@@ -504,6 +507,10 @@
. endif
convert-to-gh-tuple:
@${ECHO_MSG} ${GH_ACCOUNT}:${GH_PROJECT}:${GH_TAGNAME} ${_GH_TUPLE_OUT:S/\/$//}
+print-gh-tuple: ${_GITHUB_CLONE_DIR}
+ @git clone --recurse-submodules https://github.com/${GH_ACCOUNT}/${GH_PROJECT}.git ${_GITHUB_CLONE_DIR}/${GH_ACCOUNT}:${GH_PROJECT}
+ @${SH} ${SCRIPTSDIR}/print-submodule-gh_tuple.sh ${_GITHUB_CLONE_DIR}/${GH_ACCOUNT}:${GH_PROJECT}
+ @${RM} -rf ${_GITHUB_CLONE_DIR}/${GH_ACCOUNT}:${GH_PROJECT}
.endif # defined(USE_GITHUB)
.endif # !defined(IGNORE_MASTER_SITE_GITHUB)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jun 28, 8:20 AM (8 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34427324
Default Alt Text
D24231.id70642.diff (3 KB)
Attached To
Mode
D24231: [NEW FEATURE] print-gh-tuple: Print GH_TUPLE corresponding to submodules of a GitHub repository ${GH_ACCOUNT}/${GH_PROJECT}
Attached
Detach File
Event Timeline
Log In to Comment