Skip to content

Commit

Permalink
Merge pull request #634 from qu1queee/qu1queee/default_git_branch_fix
Browse files Browse the repository at this point in the history
Modify default branch behaviour for git repos
  • Loading branch information
openshift-merge-robot authored Mar 2, 2021
2 parents 9b1cc8a + af7d73f commit 0980094
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The `Build` definition supports the following fields:
A `Build` resource can specify a Git source, together with other parameters like:

- `source.credentials.name` - For private repositories, the name is a reference to an existing secret on the same namespace containing the `ssh` data.
- `source.revision` - An specific revision to select from the source repository, this can be a commit or branch name.
- `source.revision` - An specific revision to select from the source repository, this can be a commit or branch name. If not defined, it will fallback to the git repository default branch.
- `source.contextDir` - For repositories where the source code is not located at the root folder, you can specify this path here. Currently, only supported by `buildah`, `kaniko` and `buildpacks` build strategies.

By default, the Build controller will validate that the Git repository exists. If the validation is not desired, users can define the `build.shipwright.io/verify.repository` annotation with `false`. For example:
Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/buildrun/resources/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ func GenerateTaskRun(
strategy buildv1alpha1.BuilderStrategy,
) (*v1beta1.TaskRun, error) {

revision := "master"
// Set revision to empty if the field is not specified in the Build.
// This will force Tekton Controller to do a git symbolic-link to HEAD
// giving back the default branch of the repository
revision := ""
if build.Spec.Source.Revision != nil {
revision = *build.Spec.Source.Revision
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/buildrun/resources/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var _ = Describe("GenerateTaskrun", func() {

namespace = "build-test"
contextDir = "src"
revision = "master"
revision = ""
builderImage = &buildv1alpha1.Image{
ImageURL: "heroku/buildpacks:18",
}
Expand Down

0 comments on commit 0980094

Please sign in to comment.