Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/zsh/autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ ZI[EXTENDED_GLOB]=""
if [[ "$st" = "status" ]]; then
if (( ${+ICE2[svn]} )); then
builtin print -r -- "${ZI[col-info]}Status for ${${${local_dir:h}:t}##*--}/${local_dir:t}${ZI[col-rst]}"
( builtin cd -q "$local_dir"; command svn status -vu )
( builtin cd -q "$local_dir"; if [[ -d .git ]]; then command git status; else command svn status -vu; fi )
retval=$?
builtin print
else
Expand Down
86 changes: 60 additions & 26 deletions lib/zsh/install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
return 0
} # ]]]
# FUNCTION: .zi-mirror-using-svn [[[
# Used to clone subdirectories from Github.
# If in update mode (see $2), then invokes `svn update',
# in normal mode invokes `svn checkout --non-interactive -q <URL>'.
# In test mode only compares remote and local revision and outputs true if update is needed.
# Used to clone subdirectories from Github using git sparse-checkout.
# If in update mode (see $2), then invokes `git pull',
# in normal mode invokes `git clone' with sparse-checkout.
# In test mode only compares remote and local HEAD and outputs true if update is needed.
#
# $1 - URL
# $2 - mode, "" - normal, "-u" - update, "-t" - test
Expand All @@ -721,30 +721,64 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
builtin setopt localoptions extendedglob warncreateglobal
local url="$1" update="$2" directory="$3"

(( ${+commands[svn]} )) || \
+zi-message "{error}Warning{ehi}:{rst} Subversion not found{nl}{mmdsh}{rst} {auto}Please install it to use \`svn' ice"
(( ${+commands[git]} )) || \
+zi-message "{error}Warning{ehi}:{rst} Git not found{nl}{mmdsh}{rst} {auto}Please install it to use \`svn' ice"

# Parse GitHub URL to extract repo URL and subpath
# e.g. https://github.com/ohmyzsh/ohmyzsh/plugins/git
# -> repo_url=https://github.com/ohmyzsh/ohmyzsh subpath=plugins/git
local repo_url subpath
if [[ "$url" = *github.com* ]]; then
repo_url=${(M)url##https://github.com/[^/]##/[^/]##}
subpath=${url#$repo_url}
subpath=${subpath#/}
subpath=${subpath%/}
else
+zi-message "{error}Warning{ehi}:{rst} Non-GitHub URLs are not supported for \`svn' ice without Subversion"
return 1
fi

if [[ "$update" = "-t" ]]; then
( () { builtin setopt localoptions noautopushd; builtin cd -q "$directory"; }
local -a out1 out2
out1=( "${(f@)"$(LANG=C svn info -r HEAD)"}" )
out2=( "${(f@)"$(LANG=C svn info)"}" )

out1=( "${(M)out1[@]:#Revision:*}" )
out2=( "${(M)out2[@]:#Revision:*}" )
[[ "${out1[1]##[^0-9]##}" != "${out2[1]##[^0-9]##}" ]] && return 0
return 1
)
return $?
fi
if [[ "$update" = "-u" && -d "$directory" && -d "$directory/.svn" ]]; then
( () { builtin setopt localoptions noautopushd; builtin cd -q "$directory"; }
command svn update
return $? )
else
command svn checkout --non-interactive -q "$url" "$directory"
local local_rev remote_rev
local_rev="$(<"$directory/.zi_rev" 2>/dev/null)"
remote_rev=$(command git ls-remote "$repo_url" HEAD 2>/dev/null | command awk '{print $1}')
[[ -n "$remote_rev" && "$local_rev" != "$remote_rev" ]] && return 0
return 1
fi
return $?

# Clone to temp dir, sparse-checkout subpath, copy contents to target
local tmpdir
tmpdir=$(command mktemp -d) || return 4
{
command git clone --no-checkout --depth=1 --filter=tree:0 -q "$repo_url" "$tmpdir/repo" || return 4
( () { builtin setopt localoptions noautopushd; builtin cd -q "$tmpdir/repo"; } || return 4
if [[ -n "$subpath" ]]; then
command git sparse-checkout set --no-cone "/$subpath" 2>/dev/null
fi
command git checkout -q 2>/dev/null
) || return 4

local src_dir="$tmpdir/repo"
[[ -n "$subpath" ]] && src_dir="$tmpdir/repo/$subpath"

if [[ -d "$src_dir" ]]; then
command mkdir -p "$directory"
if [[ "$update" = "-u" ]]; then
# Remove old files except .zi metadata
command find "$directory" -maxdepth 1 -not -name '.zi' -not -name '.zi_rev' -not -path "$directory" -exec rm -rf {} + 2>/dev/null
fi
command cp -Rf "$src_dir"/(^.git)(DN) "$directory"/ 2>/dev/null
# Store revision for update checks
local rev
rev=$(command git -C "$tmpdir/repo" rev-parse HEAD 2>/dev/null)
[[ -n "$rev" ]] && builtin print -r -- "$rev" > "$directory/.zi_rev"
else
return 4
fi
} always {
command rm -rf "$tmpdir"
}
return 0
}
# ]]]
# FUNCTION: .zi-forget-completion [[[
Expand Down Expand Up @@ -935,7 +969,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
(
() { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4
(( !OPTS[opt_-q,--quiet] )) && \
+zi-message "Downloading{ehi}:{rst} {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" ({p}with Subversion{rst})"}:-" ({p}with curl, wget, lftp{rst})"}{…}"
+zi-message "Downloading{ehi}:{rst} {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" ({p}with git sparse-checkout{rst})"}:-" ({p}with curl, wget, lftp{rst})"}{…}"

if (( ${+ICE[svn]} )) {
if [[ $update = -u ]] {
Expand Down
4 changes: 2 additions & 2 deletions lib/zsh/side.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@

.zi-get-object-path snippet "$url1"
local_dirA=$reply[-3] dirnameA=$reply[-2]
[[ -d "$local_dirA/$dirnameA/.svn" ]] && {
svn_dirA=".svn"
[[ -f "$local_dirA/$dirnameA/.zi_rev" || -d "$local_dirA/$dirnameA/.svn" ]] && {
if [[ -f "$local_dirA/$dirnameA/.zi_rev" ]]; then svn_dirA=".zi_rev"; else svn_dirA=".svn"; fi
if { .zi-first % "$local_dirA/$dirnameA"; } {
fileB_there=( ${reply[-1]} )
}
Expand Down
12 changes: 6 additions & 6 deletions zi.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ ZI[TMP_SUBST]=inactive ZI[DTRACE]=0 ZI[CUR_PLUGIN]=
# Parameters - ICE. [[[
typeset -gA ZI_1MAP ZI_2MAP
ZI_1MAP=(
OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
PZT:: https://github.com/sorin-ionescu/prezto/trunk/
PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
OMZ:: https://github.com/ohmyzsh/ohmyzsh/
OMZP:: https://github.com/ohmyzsh/ohmyzsh/plugins/
OMZT:: https://github.com/ohmyzsh/ohmyzsh/themes/
OMZL:: https://github.com/ohmyzsh/ohmyzsh/lib/
PZT:: https://github.com/sorin-ionescu/prezto/
PZTM:: https://github.com/sorin-ionescu/prezto/modules/
)
ZI_2MAP=(
OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
Expand Down
Loading