File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -193,4 +193,36 @@ function M.get_tag_refs(repo, tagref)
193
193
return tags
194
194
end
195
195
196
+ --- @param repo string
197
+ function M .get_origin (repo )
198
+ return M .get_config (repo )[" remote.origin.url" ]
199
+ end
200
+
201
+ --- @param repo string
202
+ function M .get_config (repo )
203
+ local ok , config = pcall (Util .read_file , repo .. " /.git/config" )
204
+ if not ok then
205
+ return {}
206
+ end
207
+ --- @type table<string , string>
208
+ local ret = {}
209
+ --- @type string
210
+ local current_section = nil
211
+ for line in config :gmatch (" [^\n ]+" ) do
212
+ -- Check if the line is a section header
213
+ local section = line :match (" ^%s*%[(.+)%]%s*$" )
214
+ if section then
215
+ --- @type string
216
+ current_section = section :gsub (' %s+"' , " ." ):gsub (' "+%s*$' , " " )
217
+ else
218
+ -- Ignore comments and blank lines
219
+ if not line :match (" ^%s*#" ) and line :match (" %S" ) then
220
+ local key , value = line :match (" ^%s*(%S+)%s*=%s*(.+)%s*$" )
221
+ ret [current_section .. " ." .. key ] = value
222
+ end
223
+ end
224
+ end
225
+ return ret
226
+ end
227
+
196
228
return M
Original file line number Diff line number Diff line change
1
+ local Git = require (" lazy.manage.git" )
2
+
1
3
describe (" lazy" , function ()
2
4
before_each (function ()
3
5
vim .g .lazy_did_setup = false
@@ -31,5 +33,7 @@ describe("lazy", function()
31
33
assert (not neodev )
32
34
assert (Config .plugins [" neodev.nvim" ]._ .installed )
33
35
assert (not Config .plugins [" neodev.nvim" ]._ .is_local )
36
+ assert .equal (" https://github.com/folke/neodev.nvim.git" , Git .get_origin (Config .plugins [" neodev.nvim" ].dir ))
37
+ assert .equal (" https://github.com/folke/paint.nvim.git" , Git .get_origin (Config .plugins [" paint.nvim" ].dir ))
34
38
end )
35
39
end )
You can’t perform that action at this time.
0 commit comments