Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Dec 31, 2024
1 parent 68cc652 commit 06b9eb3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/git/commit_submodule_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ func (sf *CommitSubModuleFile) RefID() string {
return sf.refID
}

// SubModuleCommit submodule name and commit from a repository
type SubModuleCommit struct {
Name string
Commit string
}

// GetSubmoduleCommits Returns a list of active submodules in the repository
func GetSubmoduleCommits(ctx context.Context, repoPath string) []SubModuleCommit {
stdoutReader, stdoutWriter := io.Pipe()
Expand Down Expand Up @@ -164,8 +170,7 @@ func GetSubmoduleCommits(ctx context.Context, repoPath string) []SubModuleCommit
}

// If no commit was found for the module skip it
commit, _, err := NewCommand(ctx, "submodule", "status", name).
RunStdString(&RunOpts{Dir: repoPath})
commit, _, err := NewCommand(ctx, "submodule", "status").AddDynamicArguments(name).RunStdString(&RunOpts{Dir: repoPath})
if err != nil {
log.Debug("Submodule %s skipped because it has no commit", name)
continue
Expand Down Expand Up @@ -198,7 +203,7 @@ func GetSubmoduleCommits(ctx context.Context, repoPath string) []SubModuleCommit
// AddSubmoduleIndexes Adds the given submodules to the git index. Requires the .gitmodules file to be already present.
func AddSubmoduleIndexes(ctx context.Context, repoPath string, submodules []SubModuleCommit) error {
for _, submodule := range submodules {
if stdout, _, err := NewCommand(ctx, "update-index", "--add", "--cacheinfo", "160000", submodule.Commit, submodule.Name).
if stdout, _, err := NewCommand(ctx, "update-index", "--add", "--cacheinfo", "160000").AddDynamicArguments(submodule.Commit, submodule.Name).
RunStdString(&RunOpts{Dir: repoPath}); err != nil {
log.Error("Unable to add %s as submodule to repo %s: stdout %s\nError: %v", submodule.Name, repoPath, stdout, err)
return err
Expand Down

0 comments on commit 06b9eb3

Please sign in to comment.