From 36770c8eed6b02e83156fc216b6ed42e00349e9d Mon Sep 17 00:00:00 2001 From: Terry Lambert Date: Mon, 12 Sep 2011 16:45:22 -0700 Subject: [PATCH] Add the ability to specify "." for a project name This uses the current directory and gets the project name out of git and then maps that to the project name(s). In the case of no mapping, it dies with a message. Included more changes per review comments by David and Richard. BUG=chromium-os:20338 TEST=cd src/platform/vpd; cros-workon start . Change-Id: I6d31d63fe515558286623c177c23fa50a0977b9b Reviewed-on: http://gerrit.chromium.org/gerrit/7577 Reviewed-by: Richard Barnette Reviewed-by: David James Reviewed-by: Terry Lambert Tested-by: Terry Lambert --- cros_workon | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/cros_workon b/cros_workon index 385c940b19..ce7a983c3f 100755 --- a/cros_workon +++ b/cros_workon @@ -24,7 +24,7 @@ DEFINE_string command "git status" \ DEFINE_boolean all "${FLAGS_FALSE}" \ "Apply to all possible packages for the given command" -FLAGS_HELP="usage: $0 [flags] [|--all] +FLAGS_HELP="usage: $0 [flags] [|.|--all] commands: start: Moves an ebuild to live (intended to support development) stop: Moves an ebuild to stable (use last known good) @@ -172,8 +172,7 @@ canonicalize_name () { return 1 fi - pkgname=$(\ - echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') + pkgname=$(echo "${pkgfile}" |awk -F '/' '{ print $(NF-2) "/" $(NF-1) }') # TODO(rcui): remove special casing of chromeos-chrome here when we make it # inherit from cros-workon class. Tracked in chromium-os:19259. @@ -201,6 +200,22 @@ canonicalize_names () { echo "${names}" } +# Locate the package name based on the current directory +locate_package () { + local projectname=$(git config --get remote.cros.projectname || + git config --get remote.cros-internal.projectname) + if [ -z "${projectname}" ]; then + die "No project in git config: Can not cros_workon . here" + fi + local reponame=$(show_project_ebuild_map | + grep "^${projectname} " | cut -d" " -f2) + if [ -z "${reponame}" ]; then + die "No matching package for ${projectname}: Can not cros_workon . here" + else + echo "${reponame}" + fi +} + # Display ebuilds currently part of the live branch and open for development. show_live_ebuilds () { sed -n 's/^=\(.*\)-9999$/\1/p' "${WORKON_FILE}" @@ -334,7 +349,11 @@ else # not selected --all ATOM_LIST=$@ if [ -z "${ATOM_LIST}" ]; then die "${WORKON_CMD}: No packages specified" - elif ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then + fi + if [ "${ATOM_LIST}" = "." ]; then + ATOM_LIST=$(locate_package) + fi + if ! ATOM_LIST=$(canonicalize_names "${ATOM_LIST}"); then die "Error parsing package list" fi;; *) ;; @@ -349,5 +368,5 @@ case ${WORKON_CMD} in show_workon_ebuilds ${BOARD_KEYWORD} ;; list-all) show_all_live_ebuilds ;; iterate) ebuild_iterate "${ATOM_LIST}" ;; - *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; + *) die "$(basename $0): command '${WORKON_CMD}' not recognized" ;; esac