From patchwork Thu Sep 28 14:51:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 9976267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ACADE60365 for ; Thu, 28 Sep 2017 14:52:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EED329573 for ; Thu, 28 Sep 2017 14:52:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93FA02966D; Thu, 28 Sep 2017 14:52:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 15B8C29573 for ; Thu, 28 Sep 2017 14:52:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A7796E01F; Thu, 28 Sep 2017 14:52:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBF8F6E01F for ; Thu, 28 Sep 2017 14:52:19 +0000 (UTC) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Sep 2017 07:52:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,450,1500966000"; d="scan'208";a="904775084" Received: from jnikula-mobl2.fi.intel.com (HELO localhost) ([10.237.72.62]) by FMSMGA003.fm.intel.com with ESMTP; 28 Sep 2017 07:52:16 -0700 From: Jani Nikula To: Jani Nikula , Andrzej Hajda , dri-devel@lists.freedesktop.org Subject: [dim PATCH] dim: allow a space separated list of URLs for each repo in drm_tip_repos Date: Thu, 28 Sep 2017 17:51:47 +0300 Message-Id: <20170928145147.19196-1-jani.nikula@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <87d16a7u6x.fsf@intel.com> References: <87d16a7u6x.fsf@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: Daniel Vetter , Marek Szyprowski , Bartlomiej Zolnierkiewicz X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This lets us configure a space separated list of URLs for each repo in drm_tip_repos, with all accepted protocols and sources, and the first one found gets picked. This way we don't have to have a complicated set of rules for converting between ssh, git and https protocol URLs. Signed-off-by: Jani Nikula --- !!! UNTESTED !!! --- dim | 97 +++++++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 34 deletions(-) diff --git a/dim b/dim index c6c746cdb154..d2f165893161 100755 --- a/dim +++ b/dim @@ -255,44 +255,73 @@ fi # The below functions map between these. # -function url_to_remote # url +function url_to_remote # url [url ...] { local url remote - url="$1" - - if [[ -z "$url" ]]; then - echoerr "$0 without url" + if [[ "$#" = "0" ]]; then + echoerr "url_to_remote without URLs" return 1 fi - remote=$(git remote -v | grep -m 1 "$url" | cut -f 1) - - if [[ -z "$remote" ]]; then - git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/') - remote=$(git remote -v | grep -m 1 "$git_url" | cut -f 1) + for url; do + remote=$(git remote -v | grep -m 1 "$url" | cut -f 1) + if [[ -n "$remote" ]]; then + echo "$remote" + return 0 + fi + done - if [[ -z "$remote" ]]; then - echoerr "No git remote for url $url or $git_url found in $(pwd)" - remote=${url%.git} - remote=${remote##*/} - read -r -i "$remote" -e -p "Enter a name to auto-add this remote, leave blank to abort: " || true - if [[ "$REPLY" == "" ]] ; then - echoerr "Please set it up yourself using:" - echoerr " $ git remote add $url" - echoerr "with a name of your choice." - exit 1 - fi + echoerr "No git remote for any of the URLs $* found in $(pwd)" - git remote add $remote $url - fi + url=$1 + remote=${url%.git} + remote=${remote##*/} + read -r -i "$remote" -e -p "Enter a name to auto-add this remote, leave blank to abort: " || true + if [[ "$REPLY" == "" ]] ; then + echoerr "Please set it up yourself using:" + echoerr " $ git remote add $url" + echoerr "with a name of your choice." + exit 1 fi + git remote add $remote $url + echo $remote return 0 } +function url_to_git_url # url [url ...] +{ + local url git_url + + if [[ "$#" = "0" ]]; then + echoerr "url_to_git_url without URLs" + return 1 + fi + + # Find the git:// URL, converting from ssh:// URL as fallback + for url; do + case $url in + git://*) + git_url=$url + break + ;; + ssh://*) + git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/') + ;; + esac + done + + if [[ -z "$git_url" ]]; then + echoerr "No git or ssh URL in any of the URLs $*" + return 1 + fi + + echo $git_url +} + function branch_to_remote # branch { local branch remote @@ -595,7 +624,7 @@ function commit_rerere_cache function dim_rebuild_tip { - local integration_branch specfile time first rerere repo url remote + local integration_branch specfile time first rerere repo url_list remote integration_branch=drm-tip specfile=$(mktemp) @@ -627,8 +656,8 @@ function dim_rebuild_tip echo "Done." for repo in "${!drm_tip_repos[@]}"; do - url=${drm_tip_repos[$repo]} - remote=$(url_to_remote $url) + url_list=${drm_tip_repos[$repo]} + remote=$(url_to_remote $url_list) echo -n "Fetching $repo (local remote $remote)... " git_fetch_helper $remote echo "Done." @@ -639,8 +668,8 @@ function dim_rebuild_tip local branch override sha1 fixup_file read -r repo branch override <<< $conf - url=${drm_tip_repos[$repo]} - remote=$(url_to_remote $url) + url_list=${drm_tip_repos[$repo]} + remote=$(url_to_remote $url_list) sha1=$remote/$branch echo -n "Merging $repo (local remote $remote) $branch... " @@ -1641,7 +1670,7 @@ function prep_pull_tag_summary # dim_pull_request branch upstream function dim_pull_request { - local branch upstream remote repo req_file url git_url suffix tag + local branch upstream remote repo req_file url_list git_url suffix tag branch=${1:?$usage} upstream=${2:?$usage} @@ -1679,8 +1708,8 @@ function dim_pull_request repo=$(branch_to_repo $branch) fi - url=${drm_tip_repos[$repo]} - git_url=$(echo $url | sed -e 's/git\./anongit./' -e 's/ssh:/git:/') + url_list=${drm_tip_repos[$repo]} + git_url=$(url_to_git_url $url_list) git request-pull $upstream $git_url $tag >> $req_file $DRY $DIM_MUA -s "[PULL] $branch" \ @@ -1729,7 +1758,7 @@ function dim_list_branches dim_alias_ub=update-branches function dim_update_branches { - local repo remote + local repo remote url_list cd $DIM_PREFIX/$DIM_DRM_INTEL @@ -1740,8 +1769,8 @@ function dim_update_branches fi for repo in "${!drm_tip_repos[@]}"; do - url=${drm_tip_repos[$repo]} - if ! remote=$(url_to_remote $url 2>/dev/null); then + url_list=${drm_tip_repos[$repo]} + if ! remote=$(url_to_remote $url_list 2>/dev/null); then continue fi echo -n "Fetching $repo (local remote $remote)... "