Skip to content

Commit d8df861

Browse files
committed
Merge remote-tracking branch 'rbenv/master' into rbenv-1.0
2 parents 0efd753 + 29b4da7 commit d8df861

26 files changed

+240
-217
lines changed

.agignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
./versions
2+
./cache

.vimrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set wildignore+=versions/*,cache/*

CONDUCT.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, gender identity and expression, level of experience,
9+
nationality, personal appearance, race, religion, or sexual identity and
10+
orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting one of the project maintainers listed below. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Project Maintainers
69+
70+
* Sam Stephenson <<sstephenson@gmail.com>>
71+
* Mislav Marohnić <<mislav.marohnic@gmail.com>>
72+
* Erik Michaels-Ober <<sferik@gmail.com>>
73+
74+
## Attribution
75+
76+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
77+
available at [http://contributor-covenant.org/version/1/4][version]
78+
79+
[homepage]: http://contributor-covenant.org
80+
[version]: http://contributor-covenant.org/version/1/4/

bin/python-local-exec

Lines changed: 0 additions & 23 deletions
This file was deleted.

libexec/pyenv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ PYENV_HOOK_PATH="${PYENV_HOOK_PATH}:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib
9797
for plugin_hook in "${PYENV_ROOT}/plugins/"*/etc/pyenv.d; do
9898
PYENV_HOOK_PATH="${PYENV_HOOK_PATH}:${plugin_hook}"
9999
done
100+
PYENV_HOOK_PATH="${PYENV_HOOK_PATH#:}"
100101
export PYENV_HOOK_PATH
101102

102103
shopt -u nullglob

libexec/pyenv---version

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@ set -e
1515
version="20160202"
1616
git_revision=""
1717

18-
for source_dir in "${BASH_SOURCE%/*}" "$PYENV_ROOT"; do
19-
if cd "$source_dir" 2>/dev/null && git remote -v 2>/dev/null | grep -q pyenv; then
20-
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
21-
git_revision="${git_revision#v}"
22-
[ -z "$git_revision" ] || break
23-
fi
24-
done
18+
if cd "${BASH_SOURCE%/*}" 2>/dev/null && git remote -v 2>/dev/null | grep -q pyenv; then
19+
git_revision="$(git describe --tags HEAD 2>/dev/null || true)"
20+
git_revision="${git_revision#v}"
21+
fi
2522

2623
echo "pyenv ${git_revision:-$version}"

libexec/pyenv-hooks

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set -e
99
if [ "$1" = "--complete" ]; then
1010
echo exec
1111
echo rehash
12+
echo version-name
13+
echo version-origin
1214
echo which
1315
exit
1416
fi

libexec/pyenv-init

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ done
3333

3434
shell="$1"
3535
if [ -z "$shell" ]; then
36-
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
37-
shell="${shell##-}"
36+
shell="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)"
3837
shell="${shell%% *}"
38+
shell="${shell##-}"
3939
shell="${shell:-$SHELL}"
4040
shell="${shell##*/}"
4141
fi

libexec/pyenv-local

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
# `PYENV_VERSION' environment variable takes precedence over local
1616
# and global versions.
1717
#
18-
# For backwards compatibility, pyenv will also read version
19-
# specifications from `.pyenv-version' files, but a `.python-version'
20-
# file in the same directory takes precedence.
21-
#
2218
# <version> should be a string matching a Python version known to pyenv.
2319
# The special version string `system' will use your default system Python.
2420
# Run `pyenv versions' for a list of available Python versions.

libexec/pyenv-version-file

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
#!/usr/bin/env bash
2+
# Usage: pyenv version-file [<dir>]
23
# Summary: Detect the file that sets the current pyenv version
34
set -e
45
[ -n "$PYENV_DEBUG" ] && set -x
56

7+
target_dir="$1"
8+
69
find_local_version_file() {
710
local root="$1"
8-
while true; do
9-
[[ "$root" =~ ^//[^/]*$ ]] && break
11+
while ! [[ "$root" =~ ^//[^/]*$ ]]; do
1012
if [ -e "${root}/.python-version" ]; then
1113
echo "${root}/.python-version"
12-
exit
13-
elif [ -e "${root}/.pyenv-version" ]; then
14-
echo "${root}/.pyenv-version"
15-
exit
14+
return 0
1615
fi
1716
[ -n "$root" ] || break
1817
root="${root%/*}"
1918
done
19+
return 1
2020
}
2121

22-
find_local_version_file "$PYENV_DIR"
23-
[ "$PYENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
24-
25-
global_version_file="${PYENV_ROOT}/version"
26-
27-
if [ -e "$global_version_file" ]; then
28-
echo "$global_version_file"
29-
elif [ -e "${PYENV_ROOT}/global" ]; then
30-
echo "${PYENV_ROOT}/global"
31-
elif [ -e "${PYENV_ROOT}/default" ]; then
32-
echo "${PYENV_ROOT}/default"
22+
if [ -n "$target_dir" ]; then
23+
find_local_version_file "$target_dir"
3324
else
34-
echo "$global_version_file"
25+
find_local_version_file "$PYENV_DIR" || {
26+
[ "$PYENV_DIR" != "$PWD" ] && find_local_version_file "$PWD"
27+
} || echo "${PYENV_ROOT}/version"
3528
fi

libexec/pyenv-version-name

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ if [ -z "$PYENV_VERSION" ]; then
88
PYENV_VERSION="$(pyenv-version-file-read "$PYENV_VERSION_FILE" || true)"
99
fi
1010

11+
OLDIFS="$IFS"
12+
IFS=$'\n' scripts=(`pyenv-hooks version-name`)
13+
IFS="$OLDIFS"
14+
for script in "${scripts[@]}"; do
15+
source "$script"
16+
done
17+
1118
if [ -z "$PYENV_VERSION" ] || [ "$PYENV_VERSION" = "system" ]; then
1219
echo "system"
1320
exit

libexec/pyenv-version-origin

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33
set -e
44
[ -n "$PYENV_DEBUG" ] && set -x
55

6-
if [ -n "$PYENV_VERSION" ]; then
6+
unset PYENV_VERSION_ORIGIN
7+
8+
OLDIFS="$IFS"
9+
IFS=$'\n' scripts=(`pyenv-hooks version-origin`)
10+
IFS="$OLDIFS"
11+
for script in "${scripts[@]}"; do
12+
source "$script"
13+
done
14+
15+
if [ -n "$PYENV_VERSION_ORIGIN" ]; then
16+
echo "$PYENV_VERSION_ORIGIN"
17+
elif [ -n "$PYENV_VERSION" ]; then
718
echo "PYENV_VERSION environment variable"
819
else
920
pyenv-version-file

libexec/pyenv-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ done
2727

2828
versions_dir="${PYENV_ROOT}/versions"
2929

30-
if ! enable -f "${BASH_SOURCE%/*}"/../libexec/pyenv-realpath.dylib realpath 2>/dev/null; then
30+
if ! enable -f "${BASH_SOURCE%/*}"/pyenv-realpath.dylib realpath 2>/dev/null; then
3131
if [ -n "$PYENV_NATIVE_EXT" ]; then
3232
echo "pyenv: failed to load \`realpath' builtin" >&2
3333
exit 1

test/--version.bats

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,13 @@
22

33
load test_helper
44

5+
export GIT_DIR="${PYENV_TEST_DIR}/.git"
6+
57
setup() {
68
mkdir -p "$HOME"
79
git config --global user.name "Tester"
810
git config --global user.email "tester@test.local"
9-
10-
mkdir -p "${PYENV_TEST_DIR}/bin"
11-
cat > "${PYENV_TEST_DIR}/bin/git" <<CMD
12-
#!$BASH
13-
if [[ \$1 == remote && \$PWD != "\$PYENV_TEST_DIR"/* ]]; then
14-
echo "not allowed" >&2
15-
exit 1
16-
else
17-
exec $(which git) "\$@"
18-
fi
19-
CMD
20-
chmod +x "${PYENV_TEST_DIR}/bin/git"
11+
cd "$PYENV_TEST_DIR"
2112
}
2213

2314
git_commit() {
@@ -28,47 +19,37 @@ git_commit() {
2819
assert [ ! -e "$PYENV_ROOT" ]
2920
run pyenv---version
3021
assert_success
31-
[[ $output == "pyenv 20"* ]]
22+
[[ $output == "ybenv "?.?.? ]]
3223
}
3324

3425
@test "doesn't read version from non-pyenv repo" {
35-
mkdir -p "$PYENV_ROOT"
36-
cd "$PYENV_ROOT"
3726
git init
3827
git remote add origin https://github.com/homebrew/homebrew.git
3928
git_commit
4029
git tag v1.0
4130

42-
cd "$PYENV_TEST_DIR"
4331
run pyenv---version
4432
assert_success
45-
[[ $output == "pyenv 20"* ]]
33+
[[ $output == "pyenv "?.?.? ]]
4634
}
4735

4836
@test "reads version from git repo" {
49-
mkdir -p "$PYENV_ROOT"
50-
cd "$PYENV_ROOT"
5137
git init
5238
git remote add origin https://github.com/yyuu/pyenv.git
5339
git_commit
54-
git tag v20380119
40+
git tag v0.4.1
5541
git_commit
5642
git_commit
5743

58-
cd "$PYENV_TEST_DIR"
5944
run pyenv---version
60-
assert_success
61-
[[ $output == "pyenv 20380119-2-g"* ]]
45+
assert_success "pyenv 0.4.1-2-g$(git rev-parse --short HEAD)"
6246
}
6347

6448
@test "prints default version if no tags in git repo" {
65-
mkdir -p "$PYENV_ROOT"
66-
cd "$PYENV_ROOT"
6749
git init
6850
git remote add origin https://github.com/yyuu/pyenv.git
6951
git_commit
7052

71-
cd "$PYENV_TEST_DIR"
7253
run pyenv---version
73-
[[ $output == "pyenv 20"* ]]
54+
[[ $output == "pyenv "?.?.? ]]
7455
}

test/exec.bats

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,14 @@ python
4343
OUT
4444
}
4545

46-
@test "supports hook path with spaces" {
47-
hook_path="${PYENV_TEST_DIR}/custom stuff/pyenv hooks"
48-
mkdir -p "${hook_path}/exec"
49-
echo "export HELLO='from hook'" > "${hook_path}/exec/hello.bash"
50-
51-
export PYENV_VERSION=system
52-
PYENV_HOOK_PATH="$hook_path" run pyenv-exec env
53-
assert_success
54-
assert_line "HELLO=from hook"
55-
}
56-
5746
@test "carries original IFS within hooks" {
58-
hook_path="${PYENV_TEST_DIR}/pyenv.d"
59-
mkdir -p "${hook_path}/exec"
60-
cat > "${hook_path}/exec/hello.bash" <<SH
47+
create_hook exec hello.bash <<SH
6148
hellos=(\$(printf "hello\\tugly world\\nagain"))
6249
echo HELLO="\$(printf ":%s" "\${hellos[@]}")"
6350
SH
6451

6552
export PYENV_VERSION=system
66-
PYENV_HOOK_PATH="$hook_path" IFS=$' \t\n' run pyenv-exec env
53+
IFS=$' \t\n' run pyenv-exec env
6754
assert_success
6855
assert_line "HELLO=:hello:ugly:world:again"
6956
}

test/global.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
load test_helper
44

55
@test "default" {
6-
run pyenv global
6+
run pyenv-global
77
assert_success
88
assert_output "system"
99
}
@@ -20,7 +20,7 @@ load test_helper
2020
mkdir -p "$PYENV_ROOT/versions/1.2.3"
2121
run pyenv-global "1.2.3"
2222
assert_success
23-
run pyenv global
23+
run pyenv-global
2424
assert_success "1.2.3"
2525
}
2626

0 commit comments

Comments
 (0)