@@ -15,9 +15,12 @@ import (
1515 "github.com/github/gh-aw/pkg/constants"
1616 "github.com/github/gh-aw/pkg/fileutil"
1717 "github.com/github/gh-aw/pkg/gitutil"
18+ "github.com/github/gh-aw/pkg/logger"
1819 "github.com/github/gh-aw/pkg/workflow"
1920)
2021
22+ var addPackageOwnershipLog = logger .New ("cli:add_package_ownership" )
23+
2124const packageOwnershipSchemaVersion = 1
2225
2326type packageOwnershipRecord struct {
@@ -45,6 +48,7 @@ func writePackageOwnershipRecords(workflows []*ResolvedWorkflow, tracker *FileTr
4548 if len (groups ) == 0 {
4649 return nil
4750 }
51+ addPackageOwnershipLog .Printf ("Writing package ownership records for %d package group(s)" , len (groups ))
4852 gitRoot , err := gitutil .FindGitRoot ()
4953 if err != nil {
5054 return fmt .Errorf ("failed to find git root for package ownership records: %w" , err )
@@ -74,6 +78,7 @@ func writePackageOwnershipRecords(workflows []*ResolvedWorkflow, tracker *FileTr
7478 if err := os .WriteFile (recordPath , data , constants .FilePermPublic ); err != nil {
7579 return fmt .Errorf ("failed to write package ownership record %s: %w" , recordPath , err )
7680 }
81+ addPackageOwnershipLog .Printf ("Wrote package ownership record %s (%d file entries)" , recordPath , len (record .Files ))
7782 }
7883 return nil
7984}
@@ -208,9 +213,12 @@ func packageOwnershipAllowsOverwrite(gitRoot, destination, packageSource string)
208213 }
209214 current , err := fileSHA256 (filepath .Join (gitRoot , filepath .FromSlash (file .Destination )))
210215 if err != nil {
216+ addPackageOwnershipLog .Printf ("Ownership check for %s: package=%s owned=true drifted=true (digest read failed: %v)" , destination , packageSource , err )
211217 return true , true
212218 }
213- return true , current != file .SHA256
219+ drifted := current != file .SHA256
220+ addPackageOwnershipLog .Printf ("Ownership check for %s: package=%s owned=true drifted=%t" , destination , packageSource , drifted )
221+ return true , drifted
214222 }
215223 }
216224 return false , false
@@ -256,6 +264,7 @@ func syncManifestManagedResources(ctx context.Context, repoSpec *RepoSpec, pkg *
256264 return err
257265 }
258266 packageBase := repositoryPackageIdentifier (repoSpec .RepoSlug , repoSpec .PackagePath )
267+ addPackageOwnershipLog .Printf ("Syncing manifest-managed resources for package=%s, resource_files=%d" , packageBase , len (pkg .ResourceFiles ))
259268 recordPath := packageOwnershipRecordPath (gitRoot , packageBase )
260269 record := packageOwnershipRecord {
261270 SchemaVersion : packageOwnershipSchemaVersion ,
@@ -318,6 +327,7 @@ func syncManifestManagedResources(ctx context.Context, repoSpec *RepoSpec, pkg *
318327 }
319328 var rollbacks []fileRollback
320329 rollbackChanges := func () {
330+ addPackageOwnershipLog .Printf ("Rolling back %d file change(s) for package=%s" , len (rollbacks ), packageBase )
321331 for _ , rollback := range slices .Backward (rollbacks ) {
322332 if rollback .existed {
323333 _ = os .MkdirAll (filepath .Dir (rollback .path ), constants .DirPermPublic )
0 commit comments