Always try to get branch sha

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-13 22:43:09 +01:00
parent 53ebcdad5d
commit 5e73be42cb

View File

@@ -64,8 +64,15 @@ func (g *GithubRepositoryCreateOrUpdateContent) Run(ctx context.Context, params
result.Branch = g.defaultBranch result.Branch = g.defaultBranch
} }
var sha *string
branch, _, _ := g.client.Repositories.GetBranch(g.context, result.Owner, result.Repository, result.Branch, 2)
if branch != nil {
sha = branch.Commit.SHA
}
fileContent, _, err := g.client.Repositories.CreateFile(g.context, result.Owner, result.Repository, result.Path, &github.RepositoryContentFileOptions{ fileContent, _, err := g.client.Repositories.CreateFile(g.context, result.Owner, result.Repository, result.Path, &github.RepositoryContentFileOptions{
Message: &result.CommitMessage, Message: &result.CommitMessage,
SHA: sha,
Committer: &github.CommitAuthor{ Committer: &github.CommitAuthor{
Name: &g.commitAuthor, Name: &g.commitAuthor,
Email: &g.commitMail, Email: &g.commitMail,