Skip to content
This repository was archived by the owner on Dec 7, 2025. It is now read-only.

Commit 2a548ab

Browse files
committed
update
1 parent d2d84c1 commit 2a548ab

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

lua/strive/init.lua

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ function Plugin:has_updates()
10911091
end)()
10921092
end
10931093

1094-
function Plugin:update()
1094+
function Plugin:update(skip_check)
10951095
if self.is_local or not self.is_remote then
10961096
return Async.wrap(function(cb)
10971097
cb(true, 'skip')
@@ -1120,28 +1120,31 @@ function Plugin:update()
11201120
return
11211121
end
11221122

1123-
-- Check for updates
1124-
local updates_result = Async.try_await(self:has_updates())
1125-
local has_updates
1123+
-- Skip update check if requested
1124+
local has_updates = true
1125+
if not skip_check then
1126+
-- Check for updates
1127+
local updates_result = Async.try_await(self:has_updates())
11261128

1127-
if updates_result.success then
1128-
has_updates = updates_result.value
1129-
else
1130-
self.status = STATUS.ERROR
1131-
ui:update_entry(
1132-
self.name,
1133-
self.status,
1134-
'Error checking updates: ' .. tostring(updates_result.error)
1135-
)
1136-
callback(false, 'error_checking_updates')
1137-
return
1138-
end
1129+
if updates_result.success then
1130+
has_updates = updates_result.value
1131+
else
1132+
self.status = STATUS.ERROR
1133+
ui:update_entry(
1134+
self.name,
1135+
self.status,
1136+
'Error checking updates: ' .. tostring(updates_result.error)
1137+
)
1138+
callback(false, 'error_checking_updates')
1139+
return
1140+
end
11391141

1140-
if not has_updates then
1141-
self.status = STATUS.UPDATED
1142-
ui:update_entry(self.name, self.status, 'Already up to date')
1143-
callback(true, 'up_to_date')
1144-
return
1142+
if not has_updates then
1143+
self.status = STATUS.UPDATED
1144+
ui:update_entry(self.name, self.status, 'Already up to date')
1145+
callback(true, 'up_to_date')
1146+
return
1147+
end
11451148
end
11461149

11471150
-- Update the plugin
@@ -1172,7 +1175,16 @@ function Plugin:update()
11721175
-- Handle result
11731176
if result.success then
11741177
self.status = STATUS.UPDATED
1175-
ui:update_entry(self.name, self.status, 'Update complete')
1178+
local stdout = result.value.stdout or ''
1179+
local update_info = 'Update complete'
1180+
local commit_info = stdout:match('([a-f0-9]+)%.%.([a-f0-9]+)')
1181+
if stdout:find('Already up to date') then
1182+
update_info = 'Already up to date'
1183+
elseif commit_info then
1184+
update_info = string.format('Updated to %s', stdout:match('([a-f0-9]+)%.%.([a-f0-9]+)'))
1185+
end
1186+
1187+
ui:update_entry(self.name, self.status, update_info)
11761188
callback(true, 'updated')
11771189
else
11781190
self.status = STATUS.ERROR
@@ -1396,39 +1408,27 @@ function M.update()
13961408
end
13971409

13981410
ui:open()
1399-
1400-
-- First, fetch all repositories in parallel
1401-
local fetch_promises = {}
1411+
-- Initialize UI entries for all plugins immediately
14021412
for _, plugin in ipairs(plugins_to_update) do
1403-
local path = plugin:get_path()
1404-
table.insert(
1405-
fetch_promises,
1406-
Async.system({
1407-
'git',
1408-
'-C',
1409-
path,
1410-
'fetch',
1411-
'--quiet',
1412-
'origin',
1413-
})
1414-
)
1413+
plugin.status = STATUS.PENDING
1414+
ui:update_entry(plugin.name, plugin.status, 'Queued for update...')
14151415
end
14161416

1417-
-- Wait for all fetches to complete
1418-
Async.await(Async.all(fetch_promises))
1419-
1420-
-- Now process actual updates with TaskQueue
1417+
-- Process updates through TaskQueue
14211418
local task_queue = TaskQueue.new(DEFAULT_SETTINGS.max_concurrent_tasks)
14221419

14231420
for _, plugin in ipairs(plugins_to_update) do
14241421
task_queue:enqueue(function(done)
14251422
Async.async(function()
1423+
plugin.status = STATUS.UPDATING
1424+
ui:update_entry(plugin.name, plugin.status, 'Checking for updates...')
1425+
1426+
-- Process one plugin at a time with UI feedback
14261427
local has_updates = Async.await(plugin:has_updates())
14271428

14281429
if has_updates then
1429-
plugin.status = STATUS.UPDATING
1430-
ui:update_entry(plugin.name, plugin.status, 'Updating...')
1431-
Async.await(plugin:update())
1430+
ui:update_entry(plugin.name, plugin.status, 'Updates available, pulling changes...')
1431+
Async.await(plugin:update(true)) -- Skip redundant check
14321432
else
14331433
plugin.status = STATUS.UPDATED
14341434
ui:update_entry(plugin.name, plugin.status, 'Already up to date')

0 commit comments

Comments
 (0)