jhipster/jhipster-online

Generator Maintainence Branch (v6) is not using Main

SudharakaP opened this issue ยท 16 comments

So this one needs to go into v6 maintenance branch I think as otherwise jhipster-online wouldn't work property when creating PRs as it tries to create pull requests and merge them with the main branch.

did I do something wrong ?

@pascalgrimaud : No, it's just that I think we need to migrate changes in that PR (jhipster/generator-jhipster#12718) to the 6.x branch. Since jhipster-online runs on the 6.x branch. Since you have that branch which created the PR, would you be able to quickly merge that to 6.x as well? ๐Ÿ˜„

And after that we'll need a new release I guess. But that's fine we can wait until next release cycle if you are busy. ๐Ÿ˜„

on phone right now, I can work on new PR for v6.x_maintenance branch tomorrow. I can't merge it, as it contains some Vue file

@pascalgrimaud : Don't worry about it, I'll do the PR for that today excluding the Vue files. ๐Ÿ˜„

Thanks for your PR @SudharakaP but sorry for asking it, I don't understand how it can fix the issue

Currently, when I generate a JHipster project with JH Online, it's still with main branch

Thanks for your PR @SudharakaP but sorry for asking it, I don't understand how it can fix the issue

Currently, when I generate a JHipster project with JH Online, it's still with main branch

@pascalgrimaud : Currently when you generate a JHipster project with jhipster-online it generates it with a master branch. I see that you've created a sample repo after releasing the new version of jhipster-online; https://github.com/pascalgrimaud/jhipster-sample-application201108. Notice that this has the master branch. But ideally; that should have main branch right. Otherwise what will happen is that when we try to create the CI pull request using jhipster-online (https://start.jhipster.tech/ci-cd), it will try to push that pull request with a target branch set to main;

.createPullRequest(title, branchName, "main", body)

which will fail right? ๐Ÿ˜„

Yes you're right @SudharakaP : the CICD at start.jhipster.tech is broken:

Sending request to the server...
Continuous Integration with Github is going to be applied to pascalgrimaud/jhipster-sample-application201108
Cloning GitHub repository `pascalgrimaud/jhipster-sample-application201108`
Creating branch `jhipster-github-ci-135776999301456`
Generating Continuous Integration configuration
Running `jhipster ci-cd`
INFO! Using JHipster version installed globally
INFO! Executing jhipster:ci-cd
INFO! Congratulations, JHipster execution is complete!
Pushing the application to the GitHub remote repository
Application successfully pushed!
Creating Pull Request
Error during generation: {"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"base","code":"invalid"},{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}
Generation failed

But I still don't understand the relation between generator-jhipster and jhipster-online.
JHipster Online should generate the projects at main branch instead of master branch : currently KO
Then, all pull request should be against main branch : currently OK

Am I correct ?

@pascalgrimaud : Yes, that's my understanding as well. But the thing is JHipster Online uses the installed generator-jhispter to generate the projects. And the installed generator-jhipster is;

yarn global add generator-jhipster@6.10.5

So this one is from the v6 branch right? Which means, that generator which jhipster-online uses creates repos with a master branch. Am I missing something there? ๐Ÿ˜„

Oh ok, now I understand !
The code is here: https://github.com/jhipster/generator-jhipster/blob/be2553b1fd333d53400859e2d68c2ea69b86ecce/generators/app/index.js#L501

It should be something like that instead: git init --initial-branch=main

Another solution would be to let JHipster Online to rename the branch before pushing:
git branch -m master main

@pascalgrimaud : Ah, yes, you are right. I thought when I renamed all instances of master to main in jhipster-generator side that should be covered somewhere. I am wrong; yes we should handle that separately I think. Let me do another PR. Thanks for pointing it out. ๐Ÿ˜ƒ

I tried the last version and it works well, excepting the CICD with GitHub Actions.
I'll try to investigate later:

Sending request to the server...
Continuous Integration with Github is going to be applied to pascalgrimaud/jhipster-sample-application201111
Cloning GitHub repository `pascalgrimaud/jhipster-sample-application201111`
Creating branch `jhipster-github-ci-27945176068796`
Generating Continuous Integration configuration
Running `jhipster ci-cd`
INFO! Using JHipster version installed globally
INFO! Executing jhipster:ci-cd
INFO! Congratulations, JHipster execution is complete!
Pushing the application to the GitHub remote repository
Application successfully pushed!
Creating Pull Request
Error during generation: {"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}
Generation failed

@pascalgrimaud : For me it works. Notice that sometime back we had the following bug; #241 due to the workflow permission missing in the GitHub token. Now if you haven't done so you will have to refresh your token as indicated here;

image

Let me know if that solves the issue. ๐Ÿ˜„

@SudharakaP I get that error when I try to apply a JDL to a repository with a master branch instead of a main branch (https://github.com/ruddell/jhipsterSampleApplication). It works if I push a main branch then try to apply the JDL.

Maybe we should use the repository's default branch rather than main?

You can call getDefaultBranch() on the GHRepository or GitlabProject, for example: ruddell@60a2646. I did not test this since I don't have a local dev config set up for this project.

@ruddell: Great idea, thanks a bunch. I've tested it and your changes work very well; so I've created a PR; #264