Skip to content
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

Fix last commit API with empty repository #170

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/git/gitserver/gitaly/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (c *Client) GetRepoLastCommit(ctx context.Context, req gitserver.GetRepoLas
if err != nil {
return nil, err
}
if resp != nil {
if resp != nil && resp.Commit != nil {
commit = types.Commit{
ID: string(resp.Commit.Id),
CommitterName: string(resp.Commit.Committer.Name),
Expand Down
8 changes: 6 additions & 2 deletions component/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ func (c *ModelComponent) SDKModelInfo(ctx context.Context, namespace, name, ref,
return nil, ErrUnauthorized
}

var pipelineTag, libraryTag string
var pipelineTag, libraryTag, sha string
var tags []string
for _, tag := range model.Repository.Tags {
tags = append(tags, tag.Name)
Expand Down Expand Up @@ -528,10 +528,14 @@ func (c *ModelComponent) SDKModelInfo(ctx context.Context, namespace, name, ref,
spaceNames[idx] = s.Name
}

if lastCommit != nil {
pulltheflower marked this conversation as resolved.
Show resolved Hide resolved
sha = lastCommit.ID
}

resModel := &types.SDKModelInfo{
ID: model.Repository.Path,
Author: model.Repository.User.Username,
Sha: lastCommit.ID,
Sha: sha,
CreatedAt: model.Repository.CreatedAt,
LastModified: model.Repository.UpdatedAt,
Private: model.Repository.Private,
Expand Down