Skip to content

Commit

Permalink
feat(api): Bare update submodule added. WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKJeff16 committed Jun 4, 2024
1 parent 3498848 commit 71540d2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/user/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local M = {
highlight = require('user.highlight'),
opts = require('user.opts'),
distro = require('user.distro'),
update = require('user.update'),

---@deprecated
assoc = Util.assoc,
Expand Down
1 change: 1 addition & 0 deletions lua/user/types/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
---@field opts UserOpts
---@field types UserTypes
---@field util UserUtils
---@field update User.Update

---@type UserTypes
local M = {
Expand Down
2 changes: 2 additions & 0 deletions lua/user/types/user/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
---@field opts table
---@field check table
---@field util table
---@field update table

---@type UserSubTypes
local M = {
Expand All @@ -17,6 +18,7 @@ local M = {
maps = require('user.types.user.maps'),
opts = require('user.types.user.opts'),
util = require('user.types.user.util'),
update = require('user.types.user.update'),
}

return M
3 changes: 3 additions & 0 deletions lua/user/types/user/update.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---@class User.Update
---@field update fun(...)
---@field is_latest fun(): boolean
35 changes: 35 additions & 0 deletions lua/user/update.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---@diagnostic disable:unused-function
---@diagnostic disable:unused-local

require('user.types.user.update')
local Util = require('user.util')
local Notify = require('user.util.notify')

local notify = Notify.notify

---@type User.Update
---@diagnostic disable-next-line:missing-fields
local M = {}

function M.update(...)
local args = { ... }

local old_cwd = vim.fn.getcwd()

vim.cmd('cd ' .. vim.fn.stdpath('config'))

local cmd = {
'git',
'pull',
'--rebase',
'--recurse-submodules',
}

vim.fn.system(cmd)

vim.cmd('cd ' .. old_cwd)
end

M.update({ git = true, xd = { 'x', 'y' } })

return M

0 comments on commit 71540d2

Please sign in to comment.