Skip to content

git_utils: follow symlinked package dirs in get_file_commit_time - #153

Merged
rjd15372 merged 1 commit into
mainfrom
changelog-date-symlink
Oct 15, 2026
Merged

rjd15372 merged 1 commit into
mainfrom
changelog-date-symlink

Conversation

@rjd15372

Copy link
Copy Markdown
Collaborator

Problem

Every sync-main run created a new OBS revision (and rebuild) for ppg:staging:19/percona-pg_tde, e.g. r10 → r11 after #152 merged, and r8 → r9 earlier from the same main commit. Only debian.tar.gz differed, and the only diff inside it was the debian/changelog trailer date, which matched the CI checkout time of each run.

%!{FILE_MODIFY_DATE_RFC5322} is resolved via get_file_commit_time, which ran git log -- <path> with the path as seen through the package directory. staging/19/percona-pg_tde is a symlink into _shared/, and git tracks a symlink as a blob, so a pathspec passing through it matches nothing. The helper returned None and the macro fell back to stat().st_mtime.

Only moving-ref packages showed it (staging:19 pg_tde tracks main, so --skip-unchanged never skips it and the sources are re-rendered every run). Pinned _shared packages were affected more quietly: whenever they were promoted, the changelog carried the checkout time instead of the commit date.

Fix

  • New _git_tracked_path in percona_obs/git_utils.py: replaces each symlinked directory component with its lexical target (os.readlink + normpath, same approach as _package_pathspecs), staying inside the worktree's own path namespace.
  • get_file_commit_time passes that path to git log.

Tests

  • tests/test_shared_source.py: commit time through the link equals the direct _shared/ lookup; the rendered date macro ignores a bogus filesystem mtime. Both fail before the fix.
  • Full suite: 658 passed; black + pyright clean.
  • Real tree: staging:19 pg_tde changelog renders Thu, 17 Sep 2026 11:49:54 +0000 (author time of 73e0dde) instead of the checkout time.

After merge

The next sync-main run uploads one more pg_tde revision (changelog date switches from checkout time to commit date); from then on unchanged moving-ref packages produce identical tarballs and no new revisions.

git tracks a symlinked package directory (staging/19/pkg -> ../_shared/pkg)
as a blob, so 'git log -- staging/19/pkg/debian/changelog' matches nothing.
get_file_commit_time returned None for every file reached through such a
link and the FILE_MODIFY_DATE* macros fell back to the filesystem mtime,
i.e. the CI checkout time. For moving-ref packages that are never skipped
(staging:19 percona-pg_tde tracks main) this re-rendered debian/changelog
with a fresh timestamp on every sync-main run, uploading a different
debian.tar.gz and creating a new OBS revision plus rebuild each time.

Replace symlinked components with their lexical target before calling
git log, the same readlink+normpath approach _package_pathspecs uses.

Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
@rjd15372
rjd15372 merged commit 4b7cce8 into main Oct 15, 2026
5 checks passed
@rjd15372
rjd15372 deleted the changelog-date-symlink branch October 15, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant