File tree 4 files changed +76
-16
lines changed
4 files changed +76
-16
lines changed Original file line number Diff line number Diff line change @@ -5,14 +5,18 @@ export RIME_ROOT="$(cd "$(dirname "$0")"; pwd)"
5
5
echo " RIME_PLUGINS=${RIME_PLUGINS} " > version-info.txt
6
6
echo " librime $( git describe --always) " >> version-info.txt
7
7
8
+ function action_install_plugin() {
9
+ local plugin=" $1 "
10
+ local plugin_dir=" $2 "
11
+ echo " ${plugin} $( git -C " ${plugin_dir} " describe --always) " >> version-info.txt
12
+ if [[ -e " ${plugin_dir} /action-install.sh" ]]; then
13
+ (cd " ${plugin_dir} " ; bash ./action-install.sh)
14
+ fi
15
+ }
16
+
17
+ declare -fx action_install_plugin
18
+
8
19
if [[ -n " ${RIME_PLUGINS} " ]]; then
9
20
# intentionally unquoted: ${RIME_PLUGINS} is a space separated list of slugs
10
- bash ./install-plugins.sh ${RIME_PLUGINS}
11
- for plugin_dir in plugins/* ; do
12
- [[ -d " ${plugin_dir} " ]] || continue
13
- echo " ${plugin_dir} $( git -C " ${plugin_dir} " describe --always) " >> version-info.txt
14
- if [[ -e " ${plugin_dir} /action-install.sh" ]]; then
15
- (cd " ${plugin_dir} " ; bash ./action-install.sh)
16
- fi
17
- done
21
+ bash ./install-plugins.sh run=action_install_plugin ${RIME_PLUGINS}
18
22
fi
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ setlocal
2
2
3
3
if not defined RIME_ROOT set RIME_ROOT = %CD%
4
4
5
+ rem for GitHub pull request #1, git checkout 1/merge
6
+ set clone_options = ^
7
+ --config " remote.origin.fetch=+refs/pull/*:refs/remotes/origin/*" ^
8
+ --depth 1 ^
9
+ --no-single-branch
10
+
5
11
echo RIME_PLUGINS=%RIME_PLUGINS% > version-info.txt
6
12
echo librime >> version-info.txt
7
13
git describe --always >> version-info.txt
@@ -12,13 +18,29 @@ if defined RIME_PLUGINS (
12
18
exit /b
13
19
14
20
:install_plugin
15
- set slug = %1
16
- echo plugin: %slug%
21
+ set plugin = %1
22
+ echo plugin: %plugin%
23
+ for /f " delims=@" %%i in (" %plugin% " ) do (
24
+ set slug = %%i
25
+ goto :got_slug
26
+ )
27
+ :got_slug
28
+ if %slug% == %plugin% (
29
+ set branch =
30
+ ) else (
31
+ set branch = %plugin:*@ =%
32
+ )
17
33
set plugin_project = %slug:*/ =%
18
34
set plugin_dir = plugins\%plugin_project:librime- =%
19
- git clone --depth 1 " https://github.com/%slug% .git" %plugin_dir%
35
+ git clone %clone_options% " https://github.com/%slug% .git" %plugin_dir%
20
36
if errorlevel 1 exit /b
21
- echo %plugin_dir% >> version-info.txt
37
+ rem pull request ref doesn't work with git clone --branch
38
+ if not [%branch% ] == [] (
39
+ git -C %plugin_dir% checkout %branch%
40
+ if errorlevel 1 exit /b
41
+ )
42
+ :action_install_plugin
43
+ echo %plugin% >> version-info.txt
22
44
git -C %plugin_dir% describe --always >> version-info.txt
23
45
if exist %plugin_dir% \action-install.bat (
24
46
pushd %plugin_dir%
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ set -e
4
+
3
5
cd " $( dirname " $0 " ) "
4
6
5
- for slug in " $@ "
7
+ clone_options=(
8
+ # for GitHub pull request #1, git checkout 1/merge
9
+ --config ' remote.origin.fetch=+refs/pull/*:refs/remotes/origin/*'
10
+ # shallow clone
11
+ --depth 1
12
+ # fetch all branches
13
+ --no-single-branch
14
+ )
15
+
16
+ if [[ " ${1} " =~ run= .* ]]; then
17
+ custom_install=" ${1# run=} "
18
+ shift
19
+ fi
20
+
21
+ for plugin in " $@ "
6
22
do
23
+ if [[ " ${plugin} " =~ @ ]]; then
24
+ slug=" ${plugin%@* } "
25
+ branch=" ${plugin#*@ } "
26
+ else
27
+ slug=" ${plugin} "
28
+ branch=' '
29
+ fi
7
30
plugin_project=" ${slug##*/ } "
8
31
plugin_dir=" plugins/${plugin_project# librime-} "
9
32
if [[ -d " ${plugin_dir} " ]]
10
33
then
11
- echo " Updating plugin: ${plugin_dir} "
12
- git -C " ${plugin_dir} " checkout master
34
+ echo " Updating ${plugin} in ${plugin_dir} "
35
+ if [[ -n " ${branch} " ]]; then
36
+ git -C " ${plugin_dir} " checkout " ${branch} "
37
+ fi
13
38
git -C " ${plugin_dir} " pull
14
39
else
15
- git clone --depth 1 " https://github.com/${slug} .git" " ${plugin_dir} "
40
+ echo " Checking out ${plugin} to ${plugin_dir} "
41
+ git clone " ${clone_options[@]} " " https://github.com/${slug} .git" " ${plugin_dir} "
42
+ # pull request ref doesn't work with git clone --branch
43
+ if [[ -n " ${branch} " ]]; then
44
+ git -C " ${plugin_dir} " checkout " ${branch} "
45
+ fi
46
+ fi
47
+ if [[ -n " ${custom_install} " ]]; then
48
+ ${custom_install} " ${plugin} " " ${plugin_dir} "
16
49
fi
17
50
done
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ if(DEFINED ENV{RIME_PLUGINS})
26
26
set (plugins $ENV{RIME_PLUGINS} )
27
27
message (STATUS "Prescribed plugins: ${plugins} " )
28
28
if (NOT "${plugins} " STREQUAL "" )
29
+ string (REGEX REPLACE "@[^ ]*" "" plugins ${plugins} )
29
30
string (REGEX REPLACE "[^ ]*/(librime-)?" "" plugins ${plugins} )
30
31
string (REPLACE " " ";" plugins ${plugins} )
31
32
endif ()
You can’t perform that action at this time.
0 commit comments