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

Do not cache the output of gitAskPass #3250

Merged
merged 2 commits into from
Dec 23, 2023
Merged

Conversation

fthomas
Copy link
Member

@fthomas fthomas commented Dec 22, 2023

Prior to this change, the gitAskPass program was called once on start-up and its output was cached and used for API calls to the forge while Git itself does not cache its output but calls it anytime a password is needed. This means if the output of gitAskPass changes during a Scala Steward run, the new password is only used for Git operations but not for forge API calls.

With this change we now do the same as Git and call gitAskPass everytime the password is needed. This should make it easier to support GitHub Apps proper which require different access tokens during a run. See also #2973 (comment).

@fthomas fthomas added the enhancement New feature or request label Dec 22, 2023
@fthomas fthomas added this to the 0.29.0 milestone Dec 22, 2023
Copy link

codecov bot commented Dec 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a3a2507) 91.17% compared to head (d23c691) 91.18%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3250      +/-   ##
==========================================
+ Coverage   91.17%   91.18%   +0.01%     
==========================================
  Files         166      167       +1     
  Lines        3400     3404       +4     
  Branches      310      306       -4     
==========================================
+ Hits         3100     3104       +4     
  Misses        300      300              

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

Prior to this change, the `gitAskPass` program was called once on
start-up and its output was cached and used for API calls to the forge
while Git itself does not cache its output but calls it anytime a password
is needed. This means if the output of `gitAskPass` changes during a Scala
Steward run, the new password is only used for Git operations but not for
forge API calls.

With this change we now do the same as Git and call `gitAskPass`
everytime the password is needed. This should make it easier to support
GitHub Apps proper which require different access tokens during a run.
See also #2973 (comment).
@fthomas fthomas force-pushed the topic/do-not-cache-credentials branch from c512a04 to ff2098a Compare December 22, 2023 09:45
Copy link
Contributor

@exoego exoego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@fthomas
Copy link
Member Author

fthomas commented Dec 22, 2023

This should make it easier to support GitHub Apps proper which require different access tokens during a run.

I tried this successfully in https://github.com/scala-steward-org/scala-steward/compare/topic/gh-app-2 which modifies gitAskPass between runs for GitHub App installations.

@fthomas fthomas merged commit 556eb5c into main Dec 23, 2023
@fthomas fthomas deleted the topic/do-not-cache-credentials branch December 23, 2023 08:52
fthomas added a commit that referenced this pull request Dec 23, 2023
This removes the unnecessary `Repo` parameter from the function for
modifying requests to add authentication headers. This parameter was
added in #373 but wasn't ever used as can be observed in the diff of
`ForgeSelection`. My motivation for adding `Repo` back then was to
eventually use different credentials for different repositories
for proper GitHub App support. But #3250 demonstrates that we can
achieve this without this extra parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants