Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update gemset delete, rewrite --default to use aliases, update alias …

…to handle default, fix #492
  • Loading branch information...
commit 4f317721ec2515685261e2a08d43116e2dfabfe8 1 parent 619c8d9
@mpapis mpapis authored
Showing with 113 additions and 51 deletions.
  1. +83 −1 scripts/alias
  2. +25 −5 scripts/gemsets
  3. +5 −45 scripts/selector
View
84 scripts/alias
@@ -70,8 +70,37 @@ alias_show() {
fi
}
+alias_after_delete_default()
+{
+ rvm_log "Deleting default links/files"
+
+ for _path in $rvm_bin_path/default_* "$rvm_environments_path/default" "$rvm_wrappers_path/default"
+ do
+ [[ -f "$_path" ]] && rm -rf ${_path}
+ done
+
+ for wrapper in "$rvm_path"/wrappers/default/*
+ do
+ wrapper="${wrapper##*\/}"
+
+ if [[ -L "$rvm_bin_path/${wrapper}" ]]
+ then
+ rm -f "$rvm_bin_path/${wrapper}"
+ fi
+
+ rm -f "$rvm_bin_path/${wrapper}"
+
+ # If the RVM bin path is different from rvm_path/bin, ensure they are
+ # in sync.
+ if [[ "${rvm_bin_path}" != "${rvm_path}/bin" ]]
+ then
+ rm -f "${rvm_path}/bin/${wrapper}"
+ fi
+ done
+}
+
alias_delete() {
- echo "Deleting alias: $alias_name"
+ rvm_log "Deleting alias: $alias_name"
for link in "$rvm_rubies_path/$alias_name" ; do
if [[ -L "$link" ]] ; then rm -f $link ; fi
@@ -80,6 +109,55 @@ alias_delete() {
[[ -s "$rvm_path/config/alias" ]] || return 0
"$rvm_scripts_path"/db "$rvm_path/config/alias" "$alias_name" "delete"
+
+ if [[ "default" == "$alias_name" ]] ; then
+ alias_after_delete_default
+ fi
+}
+
+alias_after_create_default()
+{
+ rvm_log "Creating default links/files"
+
+ environment_id="${final_environment_identifier}"
+
+ if (( ${rvm_user_install_flag:=0} == 0 ))
+ then
+ # Sets up the default wrappers.
+ "$rvm_scripts_path/wrapper" "$rvm_ruby_string" --no-prefix
+ else
+ "$rvm_scripts_path/wrapper" "$rvm_ruby_string" "default"
+ fi
+
+ RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | \sed 's#^\(.*\) (.*$#\1#')"
+
+ export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION
+
+ for _path in "$rvm_environments_path" "$rvm_wrappers_path"
+ do
+ # Remove old default if it exists.
+ [[ -L "$_path/default" ]] && rm -f "$_path/default"
+ # Symlink n the new default
+ \ln -fs "$_path/$environment_id" "$_path/default"
+ done
+
+ # Copy wrapper scripts for the newly set default to the RVM bin path.
+ for wrapper in "$rvm_path"/wrappers/default/*
+ do
+ if [[ -L "$rvm_bin_path/${wrapper##*\/}" ]]
+ then
+ rm -f "$rvm_bin_path/${wrapper##*\/}"
+ fi
+
+ cp -f "$wrapper" "$rvm_bin_path/${wrapper##*\/}"
+
+ # If the RVM bin path is different from rvm_path/bin, ensure they are
+ # in sync.
+ if [[ "${rvm_bin_path}" != "${rvm_path}/bin" ]]
+ then
+ cp -f "${wrapper}" "${rvm_path}/bin/"
+ fi
+ done
}
alias_create() {
@@ -141,6 +219,10 @@ alias_create() {
"$rvm_scripts_path"/db "$rvm_path/config/alias" "$alias_name" "$final_environment_identifier"
+ if [[ "default" == "$alias_name" ]] ; then
+ alias_after_create_default
+ fi
+
else
if [[ -d "$rvm_rubies_path/$alias_name" ]] ; then
View
30 scripts/gemsets
@@ -236,6 +236,25 @@ gemset_list()
return 0
}
+gemset_after_delete_cleanup()
+{
+ rvm_gemset_name=$1
+ ruby_at_gemset=$2
+ gemdir=$3
+
+ if [[ -L "$gemdir/cache" ]]
+ then
+ rm -f "$gemdir/cache"
+ fi
+
+ (
+ for item in $( $rvm_scripts_path/alias search_by_target ${ruby_at_gemset} )
+ do
+ $rvm_scripts_path/alias delete ${item}
+ done
+ )
+}
+
gemset_delete()
{
gemsets=(${args[@]})
@@ -252,10 +271,13 @@ gemset_delete()
if [[ -n "$rvm_gemset_name" ]]
then
- gemdir="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name"
+ ruby_at_gemset="$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name"
+ gemdir="${rvm_gems_path:-"$rvm_path/gems"}/${ruby_at_gemset}"
+
if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]]
then
__rvm_rm_rf "$gemdir"
+ gemset_after_delete_cleanup $rvm_gemset_name $ruby_at_gemset $gemdir
elif [[ -d "$gemdir" ]]
then
@@ -266,11 +288,9 @@ gemset_delete()
if [[ "yes" == "$response" ]]
then
- if [[ -L "$gemdir/cache" ]]
- then
- rm -f "$gemdir/cache"
- fi
__rvm_rm_rf "$gemdir"
+ gemset_after_delete_cleanup $rvm_gemset_name $ruby_at_gemset $gemdir
+
else
rvm_log "Not doing anything, phew... close call that one eh?"
fi
View
50 scripts/selector
@@ -500,52 +500,12 @@ __rvm_use()
local environment_id="$(__rvm_env_string)"
if (( ${rvm_default_flag:=0} == 1 )) &&
- [[ "default" != "${rvm_ruby_interpreter:-""}" ]]
+ [[ "default" != "${rvm_ruby_interpreter:-}" ]] &&
+ [[ "system" != "${rvm_ruby_interpreter:-}" ]]
then
- if (( ${rvm_user_install_flag:=0} == 0 ))
- then
- # Sets up the default wrappers.
- "$rvm_scripts_path/wrapper" "$rvm_ruby_string" --no-prefix
- else
- "$rvm_scripts_path/wrapper" "$rvm_ruby_string" "default"
- fi
-
- if [[ "system" != "$rvm_ruby_interpreter" ]]
- then
- RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | \sed 's#^\(.*\) (.*$#\1#')"
-
- export GEM_HOME GEM_PATH MY_RUBY_HOME RUBY_VERSION
-
- # Switch the default alias to the new environment id
- "$rvm_scripts_path/alias" delete default &> /dev/null
- "$rvm_scripts_path/alias" create default "$environment_id" >& /dev/null
-
- for _path in "$rvm_environments_path" "$rvm_wrappers_path"
- do
- # Remove old default if it exists.
- [[ -L "$_path/default" ]] && rm -f "$_path/default"
- # Symlink n the new default
- \ln -fs "$_path/$environment_id" "$_path/default"
- done
-
- # Copy wrapper scripts for the newly set default to the RVM bin path.
- for wrapper in "$rvm_path"/wrappers/default/*
- do
- if [[ -L "$rvm_bin_path/${wrapper##*\/}" ]]
- then
- rm -f "$rvm_bin_path/${wrapper##*\/}"
- fi
-
- cp -f "$wrapper" "$rvm_bin_path/${wrapper##*\/}"
-
- # If the RVM bin path is different from rvm_path/bin, ensure they are
- # in sync.
- if [[ "${rvm_bin_path}" != "${rvm_path}/bin" ]]
- then
- cp -f "${wrapper}" "${rvm_path}/bin/"
- fi
- done
- fi
+ # Switch the default alias to the new environment id
+ "$rvm_scripts_path/alias" delete default &> /dev/null
+ "$rvm_scripts_path/alias" create default "$environment_id" >& /dev/null
fi
rvm_default_flag=0
Please sign in to comment.
Something went wrong with that request. Please try again.