Skip to content

Commit

Permalink
Change the default configuration file name.
Browse files Browse the repository at this point in the history
The default configuration file name has been moved from '.pgenv.conf'
to '.pgenv.default.conf'.
This is a more rational name and keeps simpler the juggling between the
functions that internally try to guess the PostgreSQL versions.
However, **this breaks backward compatibility** with versions of pgenv
that used the old file name style.

Fixed a few problems related to `config` when invoked without any specific
version, that was supposed to translate into `default`.

Readme updated.
  • Loading branch information
fluca1978 committed Dec 30, 2020
1 parent 71d4dc4 commit 5839e72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,15 +556,15 @@ program will work against the currently active version of PostgreSQL.
In order to start with a default configuration, use the `write` subcommand:
$ pgenv config write default
pgenv configuration file ~/.pgenv/.pgenv.conf written
pgenv configuration file ~/.pgenv/.pgenv.default.conf written
A subsequent `show` displays the defaults:
``` sh
$ pgenv config show default
# Default configuration
# pgenv configuration for PostgreSQL
# File: /home/luca/git/misc/PostgreSQL/pgenv/.pgenv.conf
# File: /home/luca/git/misc/PostgreSQL/pgenv/.pgenv.default.conf
# ---------------------------------------------------
# pgenv configuration created on mer 12 set 2018, 08.35.52, CEST
Expand Down Expand Up @@ -628,7 +628,7 @@ loss of configuration:
$ pgenv config delete
Cannot delete default configuration while version configurations exist
To remove it anyway, delete ~/.pgenv/.pgenv.conf.
To remove it anyway, delete ~/.pgenv/.pgenv.default.conf.
The `delete` subcommand deletes both the configuration file and its backup
copy. The `pgenv remove` command also deletes any configuration for the
Expand Down
16 changes: 11 additions & 5 deletions bin/pgenv
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pgenv_guess_postgresql_version() {
default)
# there is no default version, this is useful only
# for specifying the 'default configuration'
v=""
v="default"
;;
latest|earliest)
# must guess!
Expand Down Expand Up @@ -383,7 +383,7 @@ pgenv_current_postgresql_version(){
# file is provided.
pgenv_configuration_file_name(){
local v=$1
local PGENV_DEFAULT_CONFIG_FILE="${PGENV_ROOT}/.pgenv.conf"
local PGENV_DEFAULT_CONFIG_FILE="${PGENV_ROOT}/.pgenv.default.conf"

if [ ! -z "$v" ]; then
echo "${PGENV_ROOT}/.pgenv.$v.conf"
Expand Down Expand Up @@ -1284,10 +1284,16 @@ EOF
config|configuration)
action=$2

# understand the version the user wants to configure
v=$( pgenv_guess_postgresql_version $3 $4 )

if [ -z "$3" ]; then
v="default"
else
# understand the version the user wants to configure
v=$( pgenv_guess_postgresql_version $3 $4 )
fi

# get the currently in use if none specified
if [ -z "$v" ]; then
if [ -z "$v" ]; then
pgenv_exit_if_no_postgresql_in_use
v=$( pgenv_current_postgresql_version )
fi
Expand Down

0 comments on commit 5839e72

Please sign in to comment.