Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git info to context #8693

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add git info to context #8693

wants to merge 6 commits into from

Conversation

b-per
Copy link
Contributor

@b-per b-per commented Sep 22, 2023

resolves #8690

Problem

Today, it is not possible to know which branch and/or which commit dbt's current code is based on. This PR adds the variables git_branch and git_sha to the Jinja context

Solution

Add objects to the context

Still To be Done (and keen to get Core Team inputs on the 2 first ones)

  • Handle the case where --project-dir is set and not the current dir
  • Add tests
  • Handle partial parsing gracefully, forcing a full parse if any of the special_override_macros refers to git_branchorgit_sha`.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@cla-bot cla-bot bot added the cla:yes label Sep 22, 2023
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.61%. Comparing base (d912654) to head (ddd4d0d).
Report is 220 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8693      +/-   ##
==========================================
- Coverage   86.62%   86.61%   -0.01%     
==========================================
  Files         176      176              
  Lines       25663    25696      +33     
==========================================
+ Hits        22230    22257      +27     
- Misses       3433     3439       +6     
Flag Coverage Δ
integration 83.36% <90.90%> (-0.08%) ⬇️
unit 65.18% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@b-per
Copy link
Contributor Author

b-per commented Sep 25, 2023

I have now added support for project_dir, updated existing tests and added a new one.

The last pending thing would be to invalidate the partial parsing cache in case git_branch is used there but I would most likely need a bit of help from the core team for that.

@b-per b-per marked this pull request as ready for review September 25, 2023 16:25
@b-per b-per requested review from a team as code owners September 25, 2023 16:25
@b-per b-per requested review from emmyoop and aranke and removed request for a team September 25, 2023 16:25
@b-per
Copy link
Contributor Author

b-per commented Sep 25, 2023

Would there also be appetite to add this info to manifest.json and/or run_results.json?

@b-per
Copy link
Contributor Author

b-per commented Sep 26, 2023

Thinking more about it.

In order to identify that we changed branch (and that we might need to trigger a full parse in case we refer to {{ branch_name }} in one of the generate_xxx_name() ), would there be any other technical way except storing this information in the manifest?

@dataders dataders added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Sep 28, 2023
@aranke
Copy link
Member

aranke commented Sep 29, 2023

Would there also be appetite to add this info to manifest.json and/or run_results.json?

What would be the use-case here?

@dbeatty10 dbeatty10 added the community This PR is from a community member label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes community This PR is from a community member ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-3142] [Feature] Make the current git branch (if any) available in the dbt Jinja context
5 participants