diff options
author | Squibid <me@zacharyscheiman.com> | 2023-07-16 20:36:43 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2023-07-16 20:36:43 -0400 |
commit | be22f546355ffb07a53997006097069b534cb169 (patch) | |
tree | 14ed31246d0c0eea24983471a904bb18a81e950c /eatit.lua | |
parent | a19f79b53a1a654759f39a3aced0ad05ef0544ad (diff) | |
download | eat-it-be22f546355ffb07a53997006097069b534cb169.tar.gz eat-it-be22f546355ffb07a53997006097069b534cb169.tar.bz2 eat-it-be22f546355ffb07a53997006097069b534cb169.zip |
make the plugin actually work!
1. added branch checking
2. made updating work correctly
Diffstat (limited to '')
-rw-r--r-- | eatit.lua | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -114,6 +114,17 @@ local function startinstall() plugins[i]['dir'] = '~~/' end + -- get the plugins tmp download dir + local plugdir = opts.dl.dir .. '/' .. + string.match(plugins[i][1], '/([^/]+)$'):gsub('.git', '') + + -- if no specified branch we use the default + if not plugins[i]['branch'] then + plugins[i]['branch'] = testforslash( + run('git -C ' .. plugdir .. ' symbolic-ref refs/remotes/origin/HEAD') + ) + end + -- get the file's dir local pluginfile = opts.dl.dir .. '/' .. string.match(plugins[i][1], '/([^/]+)$'):gsub('.git', '') .. @@ -122,18 +133,20 @@ local function startinstall() -- get the dest dir local destfile = mp.command_native({'expand-path', '~~/'}) .. '/' .. plugins[i]['dir'] .. - '/' .. plugins[i]['file'] + '/' .. testforslash(plugins[i]['file']) - if fileexists(pluginfile) then + if fileexists(plugdir .. '/') then -- if we need to update, update - if checkupdates(i) then + if checkupdates(plugdir) then logwrite(plugins[i]['file'] .. ' is updating.') - clonegit(i) + -- make sure we are on the main branch + run('git -C ' .. plugdir .. ' checkout -q ' .. plugins[i]['branch']) + run('git -C ' .. plugdir .. ' pull') -- get the latest commits else logwrite(plugins[i]['file'] .. ' is up to date!') end else - clonegit(i) + clonegit(plugdir, i) end -- copy the file contents over to the desired location |