[PATCH v2] dim:- Clone 'maintainer-tools' if not present

Ayan Halder Ayan.Halder at arm.com
Thu Sep 5 17:01:10 UTC 2019


During 'dim setup', if $DIM_PREFIX/maintainer-tools is not present, it should
ask the user if he/she wishes to clone it. If the user does not responds 'y/Y',
it should abort the setup with an appropriate error message.

Changes from v1:
- Changed the upstream url of maintainer-tools
- Doing an ask_user() to clone maintainer-tools if it is not present.
  (Suggested by daniel.vetter at intel.com)

Signed-off-by: Ayan Kumar Halder <ayan.halder at arm.com>
---
 dim | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/dim b/dim
index 70262b60d513..f37d0de19e7f 100755
--- a/dim
+++ b/dim
@@ -78,8 +78,6 @@ dim_timestamp="$(date --utc +%Yy-%mm-%dd-%Hh-%Mm-%Ss) UTC"
 
 dim_fdo_cookie="--push-option fdo.pushedWithDim=this-was-pushed-with-dim-and-not-manually"
 
-maintainer_tools_https=https://gitlab.freedesktop.org/drm/maintainer-tools.git
-
 # Recipients for all dim based pull requests.
 # Add To: lines to the end, Cc: lines in the beginning with -c.
 dim_pull_request_recipients=(
@@ -2156,6 +2154,12 @@ function dim_update_branches
 		fi
 	done
 
+	if [ ! -d $DIM_PREFIX/maintainer-tools ]; then
+		echoerr "'maintainer-tools' directory does not exist in $DIM_PREFIX"
+		echoerr "Please run 'dim setup' first"
+		exit 1
+	fi
+
 	cd $DIM_PREFIX/maintainer-tools
 	if git_is_current_branch master || git_is_current_branch maintainer-tools; then
 		echo "Updating maintainer-tools..."
@@ -2232,6 +2236,7 @@ function dim_setup
 
 	drm_tip_ssh=ssh://git.freedesktop.org/git/drm-tip
 	linux_upstream_git=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
+	maintainer_tools_git=git at gitlab.freedesktop.org:drm/maintainer-tools.git
 
 	if [[ ! -d "$DIM_PREFIX" ]]; then
 		if ask_user "The DIM_PREFIX repository directory '$DIM_PREFIX' doesn't exist. Create?"; then
@@ -2263,7 +2268,12 @@ function dim_setup
 
 	if [[ ! -d "$(git_dir maintainer-tools)" ]]; then
 		echoerr "No maintainer-tools git checkout found in 'maintainer-tools'."
-		echoerr "dim update will not work. Please fix."
+		if ask_user "The repository 'maintainer-tools' doesn't exist. Clone upstream?"; then
+			git clone $maintainer_tools_git $DIM_PREFIX/maintainer-tools
+		else
+			echoerr "dim update will not work. Please fix."
+			exit 1
+		fi
 	fi
 
 	setup_aux_checkout rerere-cache $drm_tip_ssh drm-rerere
-- 
2.23.0



More information about the dim-tools mailing list