File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ function M.update(opts)
94
94
opts = M .opts (opts , { mode = " update" })
95
95
return M .run ({
96
96
pipeline = {
97
+ " git.origin" ,
97
98
" git.branch" ,
98
99
" git.fetch" ,
99
100
{ " git.checkout" , lockfile = opts .lockfile },
@@ -123,6 +124,7 @@ function M.check(opts)
123
124
opts = opts or {}
124
125
return M .run ({
125
126
pipeline = {
127
+ { " git.origin" , check = true },
126
128
" git.fetch" ,
127
129
" wait" ,
128
130
{ " git.log" , check = true },
137
139
function M .log (opts )
138
140
opts = M .opts (opts , { mode = " log" })
139
141
return M .run ({
140
- pipeline = { " git.log" },
142
+ pipeline = {
143
+ { " git.origin" , check = true },
144
+ " git.log" ,
145
+ },
141
146
plugins = function (plugin )
142
147
return plugin .url and plugin ._ .installed
143
148
end ,
Original file line number Diff line number Diff line change @@ -113,6 +113,30 @@ M.branch = {
113
113
end ,
114
114
}
115
115
116
+ -- check and switch origin
117
+ M .origin = {
118
+ skip = function (plugin )
119
+ if not plugin ._ .installed or plugin ._ .is_local then
120
+ return true
121
+ end
122
+ local origin = Git .get_origin (plugin .dir )
123
+ return origin == plugin .url
124
+ end ,
125
+ --- @param opts { check ?: boolean }
126
+ run = function (self , opts )
127
+ if opts .check then
128
+ local origin = Git .get_origin (self .plugin .dir )
129
+ self .error = " Origin has changed:\n "
130
+ self .error = self .error .. " * old: " .. origin .. " \n "
131
+ self .error = self .error .. " * new: " .. self .plugin .url .. " \n "
132
+ self .error = self .error .. " Please run update to fix"
133
+ return
134
+ end
135
+ require (" lazy.manage.task.fs" ).clean .run (self , opts )
136
+ M .clone .run (self , opts )
137
+ end ,
138
+ }
139
+
116
140
-- fetches all needed origin branches
117
141
M .fetch = {
118
142
skip = function (plugin )
You can’t perform that action at this time.
0 commit comments