-
Notifications
You must be signed in to change notification settings - Fork 4
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
Enable cloning of private PMR repositories #7
Conversation
It should never be a specific username/password based argument, but rather an Given the concern for backwards compatibility I might suggest having new subclasses entirely for authenticated access, and leave the current ones as unauthenticated so that new and better ways of doing this can be engineered rather than trying to extend on what I did here as a basic proof of concept type code for use cases that was never really anticipated to begin with (back before it was assumed that workflows are all public, for example). |
I've just updated the authenticated CMD classes with a |
@metatoaster, sorry for the delay. I've just added some test cases for the authenticated CMD sub-classes. These sub-classes are now tested against all of the relevant general test cases. To achieve this I have had to override a number of the test methods. I believe the test cases for the The |
Please do let me know when you are fully happy with merging these changes in and when a release need to be cut for PyPI. |
Thanks. I'm pretty happy with it, feel free to merge and release when you have the time. |
@metatoaster, could you please merge these changes in and make a PyPI release if you have the time. |
Thank you! |
Yeah but the build broke.... https://github.com/PMR2/pmr2.wfctrl/actions/runs/10209437802/job/28247454028 |
For future reference: I should have audited your pull request better, and that tests must be ensured to not actually make real request over the public Internet. |
Well, it was more hsorby's changes a while back, I am going to revert and change how these tests are done. |
Released on PyPI. |
Currently, using a
CmdWorkspace
to clone private PMR repositories is not well supported. This is because when we instantiate aCmdWorkspace
object eitherinit
orclone
will be automatically called on theCmd
instance used by theCmdWorkspace
, but there is no way to pass user credentials to theCmdWorkspace
constructor. So, for private repositories, eitherclone
will fail due to lack of authentication, orinit
will create an empty .git directory - preventing subsequentclone
commands from using that directory.To address this issue a number of changes must be made:
username
andpassword
parameters should be added to theclone
method for each of theCmd
sub-classes (DulwichDvcsCmd
,GitDvcsCmd
,MercurialDvcsCmd
).NotGitRepository
check should be added to theDulwichDvcsCmd
read_remote
method, since it may be called before the .git directory has been created. (The enclosingget_remote
method already handles the fallback case where no remote is returned byread_remote
)Additionally, we need to prevent the
CmdWorkspace
from automatically calling the non-authenticatedclone
method on initialisation, since this will throw an authentication error for private repositories. There are a few alternatives I can think of for this:init
andclone
entirely. In this case the user would need to call these methods explicitly when required after creating aCmdWorkspace
. (This change will break most of the test cases)CmdWorkspace
constructor to support passing user credentials.clone
methods check for authentication errors so that we can warn the user and skip without crashing.@metatoaster, @hsorby, let me know what you think about the last part. Maybe you can come up with a better solution.
I will update the test cases if required after the remaining changes have been made.