diff --git a/builder/git/gitserver/gitaly/commit.go b/builder/git/gitserver/gitaly/commit.go index 0af84b63..7a68945a 100644 --- a/builder/git/gitserver/gitaly/commit.go +++ b/builder/git/gitserver/gitaly/commit.go @@ -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), diff --git a/component/model.go b/component/model.go index ebc8a6c4..8b6721f8 100644 --- a/component/model.go +++ b/component/model.go @@ -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) @@ -528,10 +528,14 @@ func (c *ModelComponent) SDKModelInfo(ctx context.Context, namespace, name, ref, spaceNames[idx] = s.Name } + if lastCommit != nil { + 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,