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 support for setting up Git Credential Manager [PR possibility] #545

Open
Auroriax opened this issue Jul 4, 2023 · 6 comments
Open
Labels
enhancement New feature or request git private repo

Comments

@Auroriax
Copy link

Auroriax commented Jul 4, 2023

Context

In some cases I want to use the git credential manager, rather than the git URI rewrites that are currently done when using gitPrivateToken. For example, to work around any issues and edge cases, e.g. as described in #430.

Suggested solution

A new build parameter called gitPrivateUser (name suggestions welcome). When gitPrivateUser and gitPrivateToken are both provided, GameCI will set up the Git Credential Manager instead of git URI rewrites.

Considered alternatives

Initially I tried to resolve the underlying bug for this problem (an issue similar to #430), but sadly I don't have the experience and time to do as such. However, setting up the git credential manager was a quick addition that resolved the permission issues we were having, and are planning to use for our projects.

Originally I wanted to switch to pull in the packages via SSH, but my senior pushed back on this given the extra setup required for all developers on the team, which is why we'd prefer to use HTTPS.

Additional details

Link to discussion on the Discord server: "Bad Credentials when resolving packages with git-lfs"
Existing implementation in our fork of Unity Builder: Psylaris@5f814eb (I can make a PR if requested.)

@Auroriax Auroriax added the enhancement New feature or request label Jul 4, 2023
@Auroriax Auroriax changed the title Add support for setting up Git Credential Manager Add support for setting up Git Credential Manager [PR possibility] Jul 4, 2023
@AndrewKahr
Copy link
Member

@webbertakken Should we backport this into builder before v3?

@webbertakken
Copy link
Member

This feature looks like something that we should support to me.

It doesn't look like a breaking change to me though. Unless I'm mistaken, we can also add it after the initial v3 release.

That said, if you feel this is something we can merge in somewhat quickly then I don't see why not.

@AndrewKahr
Copy link
Member

@Auroriax Just took a look at your implementation and was wondering if you could explain what the git credential helper line is doing as I've never seen that format before: git config --global credential.helper '!f() { sleep 1; echo "username=$GIT_PRIVATE_USER"; echo "password=$GIT_PRIVATE_TOKEN"; }; f'

It would be good to have this for both Windows and Linux so I just need to know if it's cross-compatible.

@Auroriax
Copy link
Author

If I remember correctly, I was looking for a way to set up the credential manager programatically and I stumbled upon this StackOverflow answer: https://stackoverflow.com/a/59890061 . Based on their explanation I don´t think it'll work on Windows (since essentially it's a shell script) but I don´t know for sure.

(I'm on a holiday at the moment and can help out more in ~2 weeks, if still needed!)

@AndrewKahr
Copy link
Member

Thanks for the details! I think you're right about this not working on windows as we run using powershell so I don't think it's compatible. This probably won't make it in the initial v3 release then as I thought it would be a simple port but the windows side will likely be some work to convert and verify.

@xwipeoutx
Copy link

Hey, I've just stumbled upon this exact issue - what needs to be done to get it merged in to the current release? Happy to help if I can. I followed along in the discord but it also seems to have hit a dead end.

For context, this is my error output:

An error occurred while resolving packages:
  Project has invalid dependencies:
    com.atteneder.gltfast: Cannot checkout repository [https://github.com/atteneder/glTFast.git]:
      Error when executing git command. WARNING: Multiple 'url.*..insteadof' keys with the same alias: "ssh://git@github.com/"
      Downloading Documentation~/Images/Unity-glTF-workflows.png (59 KB)
      Error downloading object: Documentation~/Images/Unity-glTF-workflows.png (aa50e39): Smudge error: Error downloading Documentation~/Images/Unity-glTF-workflows.png (aa50e3980f8e9a99e53b8347cdde7e293fe37ffb5e1469640379d802ef304541): batch response: Resource not accessible by personal access token
      WARNING: Multiple 'url.*..insteadof' keys with the same alias: "ssh://git@github.com/"

      Errors logged to /github/workspace/Library/PackageCache/.tmp-289-9gHhnk9V2pJE/clone/.git/lfs/logs/20240517T003318.352323914.log
      Use `git lfs logs last` to view the log.
      error: external filter 'git-lfs filter-process' failed
      fatal: Documentation~/Images/Unity-glTF-workflows.png: smudge filter lfs failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request git private repo
Projects
None yet
Development

No branches or pull requests

5 participants