[PATCH] dim: autodetect branches in rebuild-nightly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Needs new url-mapping information in nightly.conf to work properly.

v2:
- Fix typo when calling rr_cache_dir. Oops.
- Use cut -f 1 instead of sed/regex horrors (jani).

Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxxx>
---
 dim | 50 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/dim b/dim
index 48d5e7b6477a..09879b166cee 100755
--- a/dim
+++ b/dim
@@ -197,7 +197,7 @@ function get_remote_name
 	local remote_url=$1
 
 	local remote=`git remote -v | grep $remote_url | \
-		head -n1 | sed -e 's/^\(.*\)\t.*/\1/'`
+		head -n1 | cut -f 1`
 
 	if [[ $remote == "" ]] ; then
 		echoerr No git remote for $remote_url found in `pwd`.
@@ -235,20 +235,30 @@ function dim_commit_add_tag
 	done
 }
 
+function map_nightly_remote
+{
+	local nightly_remote=$1
+	local remote_url=`eval echo "\\\$nightly_remote_url_${nightly_remote/-/_}"`
+
+	get_remote_name $remote_url
+}
+
 function update_linux_next
 {
 	cd $DIM_PREFIX/drm-intel-nightly
 
+	local nightly_origin=`map_nightly_remote origin`
+
 	# always update drm-intel-fixes
 	echo -n "Pushing drm-intel-fixes to for-linux-next-fixes... "
-	git push $DRY_RUN origin +origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
+	git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-fixes:for-linux-next-fixes >& /dev/null
 	echo "Done."
 
-	if git merge-base --is-ancestor origin/drm-intel-next-fixes origin/drm-intel-fixes ; then
+	if git merge-base --is-ancestor $nightly_origin/drm-intel-next-fixes $nightly_origin/drm-intel-fixes ; then
 		# -fixes has caught up to dinf, i.e. we're out of the merge
 		# window. Push the next queue.
 		echo -n "Out of merge window. Pushing drm-intel-next-queued to for-linux-next... "
-		git push $DRY_RUN origin +origin/drm-intel-next-queued:for-linux-next >& /dev/null
+		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-queued:for-linux-next >& /dev/null
 		echo "Done."
 	else
 		# dinf is ahead of -fixes, i.e. drm-next has already closed for
@@ -256,7 +266,7 @@ function update_linux_next
 		# for the current -next cycle. Push dinf
 
 		echo -n "Pushing drm-intel-next-fixes to for-linux-next... "
-		git push $DRY_RUN origin +origin/drm-intel-next-fixes:for-linux-next >& /dev/null
+		git push $DRY_RUN $nightly_origin +$nightly_origin/drm-intel-next-fixes:for-linux-next >& /dev/null
 		echo "Done."
 	fi
 }
@@ -272,11 +282,20 @@ function check_conflicts
 	true
 }
 
+function rr_cache_dir
+{
+	if [ -d $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ ] ; then
+		echo $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/
+	else
+		echo $DIM_PREFIX/$DIM_DRM_INTEL/.git/rr-cache/
+	fi
+}
+
 function update_rerere_cache
 {
 	cd $DIM_PREFIX/drm-intel-rerere/
 	git pull
-	cp rr-cache/* $DIM_PREFIX/drm-intel-nightly/.git/rr-cache/ -r
+	cp rr-cache/* `rr_cache_dir` -r
 	cd -
 }
 
@@ -307,9 +326,10 @@ function dim_rebuild_nightly
 	fi
 
 	for remote in $(echo $nightly_branches | tr " " "\n" | sed 's|/.*$||g' | sort -u); do
-		echo -n "Fetching $remote... "
+		local nightly_remote=`map_nightly_remote $remote`
+		echo -n "Fetching $remote (as $nightly_remote) ... "
 		# git fetch returns 128 if there's nothing to be fetched
-		git fetch $remote >& /dev/null || true
+		git fetch $nightly_remote >& /dev/null || true
 		echo "Done."
 	done
 
@@ -329,12 +349,14 @@ function dim_rebuild_nightly
 		if [[ -n $sha1 ]] ; then
 			echo -n "Using override sha1: $sha1... "
 		else
-			sha1=$branch
+			local remote=${branch%%/*}
+			local nightly_remote=`map_nightly_remote $remote`
+			sha1=`echo $branch | sed -e s/^$remote/$nightly_remote/`
 		fi
 
 		if [ $first == 1 ] ; then
+			git reset --hard $sha1 &> /dev/null
 			echo "Reset. Done."
-			git reset --hard $sha1 >& /dev/null
 			first=0
 		elif git merge --rerere-autoupdate --ff-only $sha1 >& /dev/null ; then
 			# nothing to do if just fast-forward
@@ -370,14 +392,16 @@ function dim_rebuild_nightly
 	git commit --quiet -m "$integration_branch: $time integration manifest"
 	echo "Done."
 
+	local nightly_origin=`map_nightly_remote origin`
+
 	echo -n "Pushing $integration_branch... "
-	git push $DRY_RUN origin +HEAD >& /dev/null && echo "Done."
+	git push $DRY_RUN $nightly_origin +HEAD >& /dev/null && echo "Done."
 
 	echo -n "Updating rerere cache... "
 	cd $rerere
 	if git branch | grep rerere-cache | grep '\*' >& /dev/null ; then
 		git pull >& /dev/null
-		cp $DIM_PREFIX/$integration_branch/.git/rr-cache/* rr-cache -r
+		cp `rr_cache_dir` rr-cache -r
 		git add *.patch >& /dev/null || true
 		git add rr-cache/* > /dev/null
 		if git commit -m "$time: $integration_branch rerere cache update" >& /dev/null; then
@@ -386,7 +410,7 @@ function dim_rebuild_nightly
 			echo -n "Nothing changed. "
 		fi
 		echo -n "Pushing rerere cache... "
-		git push $DRY_RUN origin HEAD >& /dev/null && echo "Done."
+		git push $DRY_RUN $nightly_origin HEAD >& /dev/null && echo "Done."
 	else
 		echo "Fail: Branch setup for the rerere-cache is borked."
 		exit 1
-- 
2.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux