mirror of
https://github.com/pyenv/pyenv-update.git
synced 2025-11-08 03:23:48 -05:00
create project
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.swo
|
||||||
|
*.swp
|
||||||
20
LICENSE
Normal file
20
LICENSE
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Copyright (c) 2013 Yamashita, Yuu
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
52
README.md
Normal file
52
README.md
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# pyenv-update
|
||||||
|
|
||||||
|
pyenv-update is a [pyenv](https://github.com/yyuu/pyenv) plugin
|
||||||
|
that provides a `pyenv update` command to update pyenv and its plugins.
|
||||||
|
|
||||||
|
This plugin was inspired from [rbenv-update](https://github.com/rkh/rbenv-update).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Installing as a pyenv plugin
|
||||||
|
|
||||||
|
Installing pyenv-update as a pyenv plugin will give you access to the
|
||||||
|
`pyenv update` command.
|
||||||
|
|
||||||
|
$ git clone git://github.com/yyuu/pyenv-update.git ~/.pyenv/plugins/pyenv-update
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
To update pyenv and plugins (including pyenv-update itself), just type `pyenv update`.
|
||||||
|
|
||||||
|
$ pyenv update
|
||||||
|
|
||||||
|
## Version History
|
||||||
|
|
||||||
|
#### 20130531
|
||||||
|
|
||||||
|
* Initial public release.
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
* Copyright (c) 2013 Yamashita, Yuu
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
59
bin/pyenv-update
Executable file
59
bin/pyenv-update
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
if [ -z "$PYENV_ROOT" ]; then
|
||||||
|
PYENV_ROOT="${HOME}/.pyenv"
|
||||||
|
fi
|
||||||
|
|
||||||
|
verify_repo_origin() {
|
||||||
|
local repo="$1"
|
||||||
|
( cd "${repo}" && git remote show origin 1>/dev/null 2>&1 ) || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_repo_master() {
|
||||||
|
local repo="$1"
|
||||||
|
local name="$(cd "${repo}" && git name-rev --name-only HEAD 2>/dev/null)"
|
||||||
|
[[ "${name}" == "master" ]] || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_repo_clean() {
|
||||||
|
local repo="$1"
|
||||||
|
if ( cd "${repo}" | git status --short ) | grep -q -v '^[!?][!?]'; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
verify_repo() {
|
||||||
|
local repo="$1"
|
||||||
|
if ! verify_repo_origin "${repo}"; then
|
||||||
|
echo "pyenv: ${repo} does not have origin." 1>&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! verify_repo_master "${repo}"; then
|
||||||
|
echo "pyenv: ${repo} is not on master branch." 1>&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! verify_repo_clean "${repo}"; then
|
||||||
|
echo "pyenv: ${repo} is not clean" 1>&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_repo() {
|
||||||
|
local repo="$1"
|
||||||
|
if ! verify_repo "${repo}"; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
( cd "${repo}" && git pull origin master )
|
||||||
|
}
|
||||||
|
|
||||||
|
for repo in "${PYENV_ROOT}" "${PYENV_ROOT}/plugins/"*; do
|
||||||
|
if [ -d "${repo}/.git" ]; then
|
||||||
|
echo "Updating ${repo}..." 1>&2
|
||||||
|
update_repo "${repo}" || exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user