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

[cli] check main after master #8463

Merged
merged 8 commits into from
Nov 19, 2021

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Nov 19, 2021

Description

If no branch is specified, probe master, then probe main before failing.

Fixes #8428

I would be curious if anyone has a different idea on how to download branches from both master and main without breaking changes.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@iwahbe iwahbe added the area/cli UX of using the CLI (args, output, logs) label Nov 19, 2021
@iwahbe iwahbe self-assigned this Nov 19, 2021
@iwahbe iwahbe requested a review from a team November 19, 2021 19:29
@justinvp
Copy link
Member

justinvp commented Nov 19, 2021

Allow the user to specify the branch they want to download as part of pulumi new using the pulumi new https://github.com/pierskarsenbarg/new-pulumi#main syntax

Why do we need this? It's already possible to do this via:

pulumi new https://github.com/pierskarsenbarg/new-pulumi/tree/main

If no branch is specified, probe master, then probe main before failing.

This makes sense to me.

@iwahbe
Copy link
Member Author

iwahbe commented Nov 19, 2021

Why do we need this? It's already possible to do this via:

pulumi new https://github.com/pierskarsenbarg/new-pulumi/tree/main

I didn't catch that. I removed the new version.

Copy link
Member

@pgavlin pgavlin left a comment

Choose a reason for hiding this comment

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

Could we add a couple unit tests for the repo URL parser? LGTM otherwise.

@iwahbe
Copy link
Member Author

iwahbe commented Nov 19, 2021

@pgavlin Did you have a specific thing to test in mind? We already have

func TestParseGitRepoURL(t *testing.T) {
test := func(expectedURL string, expectedURLPath string, rawurl string) {
actualURL, actualURLPath, err := ParseGitRepoURL(rawurl)
assert.NoError(t, err)
assert.Equal(t, expectedURL, actualURL)
assert.Equal(t, expectedURLPath, actualURLPath)
}
// GitHub.
pre := "https://github.com/pulumi/templates"
exp := pre + ".git"
test(exp, "", pre+".git")
test(exp, "", pre)
test(exp, "", pre+"/")
test(exp, "templates", pre+"/templates")
test(exp, "templates", pre+"/templates/")
test(exp, "templates/javascript", pre+"/templates/javascript")
test(exp, "templates/javascript", pre+"/templates/javascript/")
test(exp, "tree/master/templates", pre+"/tree/master/templates")
test(exp, "tree/master/templates/python", pre+"/tree/master/templates/python")
test(exp, "tree/929b6e4c5c39196ae2482b318f145e0d765e9608/templates",
pre+"/tree/929b6e4c5c39196ae2482b318f145e0d765e9608/templates")
test(exp, "tree/929b6e4c5c39196ae2482b318f145e0d765e9608/templates/python",
pre+"/tree/929b6e4c5c39196ae2482b318f145e0d765e9608/templates/python")
// Gists.
pre = "https://gist.github.com/user/1c8c6e43daf20924287c0d476e17de9a"
exp = "https://gist.github.com/1c8c6e43daf20924287c0d476e17de9a.git"
test(exp, "", pre)
test(exp, "", pre+"/")
testError := func(rawurl string) {
_, _, err := ParseGitRepoURL(rawurl)
assert.Error(t, err)
}
// No owner.
testError("https://github.com")
testError("https://github.com/")
// No repo.
testError("https://github.com/pulumi")
testError("https://github.com/pulumi/")
// Not HTTPS.
testError("http://github.com/pulumi/templates.git")
testError("http://github.com/pulumi/templates")
}

@iwahbe iwahbe changed the title Iwahbe/8428/new cmd allow specifying branch [cli] check main after master Nov 19, 2021
@iwahbe iwahbe requested a review from pgavlin November 19, 2021 20:41
@pgavlin
Copy link
Member

pgavlin commented Nov 19, 2021

Did you have a specific thing to test in mind? We already have

Nope, those preexisting tests look good!

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

Comment on lines 3 to 4
- [cli] - Allow specifying branch with `#branch` in `pulumi new`.
[#8463](https://github.com/pulumi/pulumi/pull/8463)
Copy link
Member

Choose a reason for hiding this comment

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

Update to reflect the changes in the PR.

We only talk about the master -> main probing, because that is all the
PR does. It used to duplicate another feature.
@iwahbe iwahbe merged commit 7222e55 into master Nov 19, 2021
@pulumi-bot pulumi-bot deleted the iwahbe/8428/new-cmd-allow-specifying-branch branch November 19, 2021 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli UX of using the CLI (args, output, logs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running pulumi new against a github repo without a master branch fails
3 participants