-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Laying the groundwork for the git
refactor
#50
Conversation
So this generally would have a structure like the following? switch (platform.toLowerCase) {
case "gitlab":
return getGitlabAuth(user, ...);
case "bitbucket":
return getBBAuth(user, ...);
case "sourceforge":
return getSFAuth(user, ...);
default:
return getGitHubAuth(user, ...);
} On PHP I would make a class/interface and inherit for each platform, but is this doable on Javascript? |
@confused-Techie see if this could be useful: https://javascript.info/class-inheritance class Github {
constructor() {
// Github platform
}
auth() {
// GH auth
}
owner() {
// GH owner
}
// ...
}
class Gitlab extends Github {
constructor() {
// Gitlab platform
}
auth() {
// GL auth overrides GH
}
owner() {
// GL owner overrides GH
}
// ...
} |
Gitlab extending Github doesn't make sense. Maybe create a generic Git class. |
If there were interfaces, it's a good idea, but there aren't in JS, so you have to define a default and we use Github at the moment. Otherwise we could define a base git, then extend to Github, but git methods what do they do? Should they be empty and return nothing? |
If the Git class would be empty inhertens is usless and could cause confusion |
So you would define a base class Git which works for Github? If yes, I'd say call it Github directly. :) |
What is the list of forges you want to support?
One major service I would include is CodeBerg (https://codeberg.org/) (Gitea/Forejo based). What about self hosted repos for GitLab, Gitea, Gogs, Forgejo? (Again just laying options out there, not that we have to support everything). |
Appreciate you guys chiming in, was not expected so much feedback here. But @Daeraxa that list is 100% correct for what I was planning to try and support, we could add Codeberg as well. The big thing to see is if we will be able to, but if we want to we should start trying to identify their repos, but support can always also be added later. And to @Digitalone1 my original idea was to essentially have something like But you idea of class inheritance could be interesting, suppose it depends on how much shared code there would be per implementation, but I'll look further into it, appreciate the idea! |
@Daeraxa as for self hosted support, keep in mind that currently all this section is able to do is detect what you are on, which is really just the precursor to supporting these services. I'd love to support self-hosted solutions, but would have to identify a way to auto-detect their usage, which likely could come at the cost of hitting the server and hopefully there are some headers there describing the service, which may have the name there. So to find out if this is possible, maybe do you know of any self-hosted instances of these services that I would be able to send a few web requests out to? |
src/vcs_providers_tests/github/fixtures/doesUserhaveRepo_authFirstPage.js
Fixed
Show fixed
Hide fixed
src/vcs_providers_tests/github/fixtures/doesUserhaveRepo_authFirstPage.js
Fixed
Show fixed
Hide fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small typo (I assume).
Yeah essentially the eventually goal if it would be something like this. The class Plus then if we want to repository or some other value, we don't have to look for it, it's just But we could do something like that, for now I'm leaving it a bit agnostic in implementation details to see if I did want to move it out for us elsewhere, But the Have that contain functions were we can say add these versions, rather than having to it ourselves in our Package Publish and Version Publish. But I'm hoping to have some time today to work on this. As for you last comment, feel free to address those concerns as I'll be at work for the next few hours, otherwise will try and get to it once home. |
Did in #61 |
Fix lexical scoping in switch + cleanup
@@ -705,9 +719,10 @@ | |||
// From the newest updated `package.json` info, just in case it's changed that will be | |||
// supported here | |||
|
|||
ownerRepo = utils.getOwnerRepoFromPackage(packJSON); | |||
ownerRepo = utils.getOwnerRepoFromPackage(packMetadata.content.metadata); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
Co-Authored-By: Giusy Digital <[email protected]>
This PR is now good to review, like I've explained above, while there are still areas to improve, it's been long enough, and theres enough changes waiting on it. I didn't mean for this PR to take as much time and effort as it has. But here we go |
Alright, as the changes here have been substantially discussed and worked on together, I'll go ahead and merge these changes. I may not have the time to update production with the new code today, but if we would like to get any other changes in that build off of this we can do so before we bump the backend version and update prod. Thanks again to all the fantastic help that has been received on this PR. |
Requirements
Filling out the template is required.
All new code requires tests to ensure against regressions.
Have you ran tests against this code?
This PR contains zero code changes.
Description of the Change
Alright, to get some things out of the way.
This PR is essentially a Minimum Viable Product. There are still many things that we should to to improve this, as well as many changes from #74 that I would still like to implement via Cherry-Picks.
But this PR has now been up for quite some time, and has seen much much activity. I think it's a good time to get these changes in and work with smaller more manageable changes for other needed improvements.
So while there are still things that we need and want to do, this should fully function as of now, even if not perfect.
With that out of the way onto the actual PR description:
This PR refactors our GitHub interaction. Namely by removing
git.js
entirely. This adds a VCS Service system, that will ideally allow us to seamlessly support as many Git providers as we want in the future with a few small hurdles to overcome to do so.This PR also resolves the complexity that arose out of having to handle internal functions to
git.js
withinpackage_handler.js
to accomplish everything we needed to.Additionally this PR covers the host of issues we have seen while creating our interactions with the package, and as seen on #78 does resolve some issues actively affecting package maintainers.
Which as a note, as far as I can tell currently no package maintainers are able to publish new changes to the backend. So this should be merged as soon as we can.
Otherwise this PR does increase the complexity within our testing framework quite a bit, but only because it is supporting a new testing style I would like to move other interactions to.
The new testing style within VCS services allows us to easily mock the underlying API calls for git related tests so that we are total in control of all interactions. This is amazing because it allows us to eventually remove the internal ExpressJS server that is propped up for testing the
git.js
module. While also letting us 100% test the module as we still can use the actual API calls for testing.Although that isn't totally what's happening due to making sure our VCS exported functions are still compliant with the old
git.js
testing style.So with that to say, all changes from main should still be here, #74 should still be left open to grab the last changes we want from it. And this should be merged as soon as we can to resolve public facing issues, and allow other PRs that rely on these changes to move forward. Then lastly any improvements or smaller changes that should be made to this PR can be made in a much more manageable state.
A huge thanks to everyone that has helped on this PR, it takes a village, and I appreciate all of you!