Skip to content

fix(git_util): derive pack first-created date from the add commit - #5504

Open
rshunim wants to merge 6 commits into
masterfrom
CRTX-221269-fix-pack-first-created-date
Open

fix(git_util): derive pack first-created date from the add commit#5504
rshunim wants to merge 6 commits into
masterfrom
CRTX-221269-fix-pack-first-created-date

Conversation

@rshunim

@rshunim rshunim commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Related Issues

fixes: https://jira-dc.paloaltonetworks.com/browse/CRTX-221269

Description

Derive the file creation date from the commit that first added the file (following renames) instead of the oldest reachable commit, and log a warning when the result may be unreliable (for example, a shallow clone).

Derive the file creation date from the commit that first added the file
(following renames) instead of the oldest reachable commit, and log a
warning when the result may be unreliable (for example, a shallow clone).

CRTX-221269
@rshunim rshunim self-assigned this Aug 20, 2026
@github-actions

Copy link
Copy Markdown

Changelog(s) in markdown:

  • Fixed an issue where the pack First Created (firstCreated) date could be inaccurate. The date is now derived from the commit that first added the pack metadata file (following renames), and a warning is logged when the result may be unreliable (for example, in a shallow clone). #5504

The tests commit via the git CLI, which fails when no user.name/user.email
is configured (for example, on a CI runner). Pass an explicit author and
committer identity through the commit environment.
@rshunim
rshunim marked this pull request as ready for review August 20, 2026 10:50
@rshunim
rshunim requested a review from a team as a code owner August 20, 2026 10:50
@rshunim

rshunim commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Checked for both cases, when a pack like Base contains the "created" filed in its metadata and the other case for "AHA" and "Traceable" which have not this field and made sure in this case the first commit is being taken.

TestSuite.repo.Repo.create_pack replaces GitUtil.get_file_creation_date with
a MagicMock on the class and never restores it, so a test that ran earlier in
the suite leaked the mock into these tests and they asserted against the
mocked date. Restore the real implementation via a fixture.
Git 2.5x renders a zero UTC offset in '%aI' as a 'Z' suffix, which
datetime.fromisoformat only accepts from Python 3.11 onwards. On Python
3.10 the resulting ValueError made get_file_creation_date fall back to
iter_commits, which doesn't follow renames, so the returned date was the
rename commit's rather than the add commit's.

CRTX-221269
@coveralls

coveralls commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 32458127194

Warning

No base build found for commit bf4825c on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 86.615%

Details

  • Patch coverage: 6 uncovered changes across 1 file (17 of 23 lines covered, 73.91%).

Uncovered Changes

File Changed Covered %
demisto_sdk/commands/common/git_util.py 23 17 73.91%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 62665
Covered Lines: 54277
Line Coverage: 86.61%
Coverage Strength: 1.73 hits per line

💛 - Coveralls

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.

2 participants