diff --git a/reports/report-template.html b/reports/report-template.html index c6102fe..080e393 100644 --- a/reports/report-template.html +++ b/reports/report-template.html @@ -31,9 +31,6 @@

{{ $category }}

{{ .SDK.Name }} - -

{{ .SDK.SubmoduleCommit }}

-

{{ .SDK.SubmoduleCommitBehind }}

{{ end }} @@ -85,9 +82,6 @@

{{ $category }}

{{ .SDK.Name }} - -

{{ .SDK.SubmoduleCommit }}

-

{{ .SDK.SubmoduleCommitBehind }}

{{ end }} @@ -115,6 +109,37 @@

{{ $category }}

{{ end }} {{ end }} + +
+

SDK Repository Submodule Information

+ + + + + + + + + + + {{ range $.Web5Reports }} + + + + + + + {{ end }} + {{ range $.TbdexReports }} + + + + + + + {{ end }} + +
SDKRepositorySubmodule CommitCommits Behind
{{ .SDK.Name }}{{ .SDK.Repo }}{{ .SDK.SubmoduleCommit }}{{ .SDK.SubmoduleCommitBehind }}
{{ .SDK.Name }}{{ .SDK.Repo }}{{ .SDK.SubmoduleCommit }}{{ .SDK.SubmoduleCommitBehind }}
Report generated on: {{ .CreationTime }} diff --git a/reports/sdks.go b/reports/sdks.go index 2da19ef..5ff70a2 100644 --- a/reports/sdks.go +++ b/reports/sdks.go @@ -365,7 +365,9 @@ func CheckSubmoduleStatus2(ctx context.Context) error { tbdexOpt.Page = resp.NextPage } - for _, sdk := range SDKs { + // Iterate using index to modify the original SDKMeta in the slice + for i := range SDKs { + sdk := &SDKs[i] // Get the pointer to the current SDKMeta in the slice // default values sdk.SubmoduleCommit = "-" @@ -416,127 +418,6 @@ func CheckSubmoduleStatus2(ctx context.Context) error { return nil } -func CheckSubmoduleStatus(ctx context.Context) error { - for _, sdk := range SDKs { - owner, repo, _ := strings.Cut(sdk.Repo, "/") - - // Determine submodule name based on SDK type - submoduleName := "web5-spec" - if sdk.Type == "tbdex" { - submoduleName = "tbdex" - } - - // Get the current submodule commit - submoduleRef, _, err := gh.Git.GetRef(ctx, owner, repo, "heads/main") - if err != nil { - return fmt.Errorf("error getting ref for %s: %v", sdk.Repo, err) - } - - tree, _, err := gh.Git.GetTree(ctx, owner, repo, *submoduleRef.Object.SHA, true) - if err != nil { - return fmt.Errorf("error getting tree for %s: %v", sdk.Repo, err) - } - - var submoduleCommit string - for _, entry := range tree.Entries { - if *entry.Path == submoduleName { - submoduleCommit = *entry.SHA - break - } - } - - if submoduleCommit == "" { - fmt.Printf("submodule %s not found in %s\n", submoduleName, sdk.Repo) - continue - } - - // Get the latest commit of the submodule repo - submoduleOwner := "TBD54566975" - submoduleRepo := submoduleName - latestCommit, _, err := gh.Repositories.GetCommit(ctx, submoduleOwner, submoduleRepo, "main", nil) - if err != nil { - return fmt.Errorf("error getting latest commit for %s: %v", submoduleRepo, err) - } - - // Manual count of commits behind or ahead - commits, _, err := gh.Repositories.ListCommits(ctx, submoduleOwner, submoduleRepo, &github.CommitsListOptions{ - SHA: "main", - }) - if err != nil { - return fmt.Errorf("error listing commits for %s: %v", submoduleRepo, err) - } - - var commitsBehind int - var commitsAhead int - var found bool - - for i, commit := range commits { - if *commit.SHA == submoduleCommit { - commitsBehind = i - found = true - break - } - } - - if !found { - // If not found, the submodule might be ahead - //commits, _, err = gh.Repositories.ListCommits(ctx, submoduleOwner, submoduleRepo, &github.CommitsListOptions{ - // SHA: submoduleCommit, - //}) - - commits, _, err := gh.Repositories.ListCommits(ctx, submoduleOwner, submoduleRepo, &github.CommitsListOptions{ - SHA: "main", - ListOptions: github.ListOptions{ - PerPage: 100, // Increase this number to retrieve more commits per page - }, - }) - - if err != nil { - return fmt.Errorf("error listing commits for %s: %v", submoduleRepo, err) - } - - for i, commit := range commits { - if *commit.SHA == *latestCommit.SHA { - commitsAhead = i - found = true - break - } - } - } - - if !found { - slog.Warn("Unable to determine relative position of submodule", - "repo", sdk.Repo, - "submodule", submoduleName, - "submodule_commit", submoduleCommit[:7], - "main_commit", (*latestCommit.SHA)[:7]) - } else if commitsBehind > 0 { - slog.Info("Submodule status", - "repo", sdk.Repo, - "submodule", submoduleName, - "submodule_commit", submoduleCommit[:7], - "main_commit", (*latestCommit.SHA)[:7], - "commits_behind", commitsBehind) - } else if commitsAhead > 0 { - slog.Info("Submodule status", - "repo", sdk.Repo, - "submodule", submoduleName, - "submodule_commit", submoduleCommit[:7], - "main_commit", (*latestCommit.SHA)[:7], - "commits_ahead", commitsAhead) - } else { - slog.Info("Submodule is up to date", - "repo", sdk.Repo, - "submodule", submoduleName, - "commit", submoduleCommit[:7]) - } - - slog.Info("--------------------") - } - - return nil -} - // Used for testing purposes func downloadLocal(ctx context.Context, sdk SDKMeta) ([]byte, error) { //data, err := os.ReadFile("../tbdex-junit-results.zip")