login

<     >

2022-02-26 18:20:30 (UTC-03:00)

Marcel Rodrigues <marcelgmr@gmail.com>

add Repo:branches()

diff --git a/git.lua b/git.lua
index 9b4b38a..8b14409 100644
--- a/git.lua
+++ b/git.lua
@@ -123,6 +123,17 @@ function Repo:refs()
     return refs
 end
 
+function Repo:branches()
+    local branches = {}
+    for _, ref in ipairs(self:refs()) do
+        local branch_name = ref:match("refs/heads/(.*)")
+        if branch_name ~= nil then
+            table.insert(branches, branch_name)
+        end
+    end
+    return branches
+end
+
 function Repo:tags()
     local strarr = ffi.new("git_strarray[1]")
     C.git_tag_list(strarr, self.repo)