New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suggestion: use a native golang git library instead of binary #10
Comments
That's a great suggestion! However, I cannot figure out how to properly implement the // `sema -a` will result in the following:
a.workTree.AddGlob(".") will not actually stage that deletion (at least on my computer). Please see this file to review my failed attempt. I have created this PR to work on the issue and I'd really appreciate your help with this one since you already have experience with the library. Have you got any spare time to help? |
Hmmm, so the problem is still there... I've found an already opened issue relating this problem. It also has a PR but it hasn't beed merged yet... My workaround was to use (unfortunatly) the edit: if you want to check out what I did => https://github.com/DataHearth/config-mapper/blob/main/internal/git/git.go . |
Ok, it seems to work :). Here's how I did it w, err := r.repository.Worktree()
if err != nil {
return err
}
status, err := w.Status()
if err != nil {
return err
}
for file := range status {
_, err = w.Add(file)
if err != nil {
return err
}
} You first get your working tree then get its status (equivalent to |
Thanks so much for this, @DataHearth. I've rewritten most of the functionality by now. Last question (I hope): is there a way to enact |
Sure ! You can use your repository to push changes repo, err := git.PlainOpen(".")
...
// add your thing, status, worktree, etc
err := repo.Push(&git.PushOptions{}) There you go :) |
What about authentication, @DataHearth? When I used this method, I get
Am I supposed to parse git configs myself to get this to work? |
Hey, I encoutered another issue (but quite similar to this one actually) a while ago and resolved it using this issue go-git/go-git#411 |
I tried this fix, @DataHearth, but it didn't do much for me on MacOS. The error message is still the same. It looks like the rest of the functionality is in order and works fine with go-git so here's what I'm going to do: I'm gonna merge this pull request without the changes to the I'll open an issue just for the push with go-git and I would welcome you to open a PR with a proposition for a stable fix for this. Then I'll test it on MacOS and Linux and if it works, we'll merge it. |
Hey! I've been browsing your code to understand how to build up
sema
and I came across the git section in agent/agent.go.I think using a native golang git library would be a great addition as you'll abstract
sema
from thegit
binary (which may differ from a system to another).I've been using this library (which is listed on the
git-scm
website). It's a great and efficient library.This should be simple to implement as you don't extensively rely on git commands.
The text was updated successfully, but these errors were encountered: