mirror of
https://github.com/tektoncd/catalog.git
synced 2024-11-29 06:34:08 +00:00
22983dbc28
Annotation about linux/amd64, linux/s390x, and linux/ppc64le platforms was added to the latest versions of the git-batch-merge, git-clone, git-rebase tasks. Platforms annotation was changed for git-version task, leaving only linux/amd64. Signed-off-by: Yulia Gaponenko <yulia.gaponenko1@de.ibm.com>
127 lines
3.6 KiB
YAML
127 lines
3.6 KiB
YAML
apiVersion: tekton.dev/v1beta1
|
|
kind: Task
|
|
metadata:
|
|
name: git-rebase
|
|
labels:
|
|
app.kubernetes.io/version: "0.1"
|
|
annotations:
|
|
tekton.dev/pipelines.minVersion: "0.12.1"
|
|
tekton.dev/categories: Git
|
|
tekton.dev/tags: git
|
|
tekton.dev/displayName: "git rebase"
|
|
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
|
|
spec:
|
|
description: >-
|
|
These Tasks are Git tasks to work with repositories used by other tasks
|
|
in your Pipeline.
|
|
|
|
This task will rebase the branch based on the user input. Before rebase,
|
|
if squashing of the commits is required, then it can be done by providing
|
|
the squash count i.e number of commits to squash.
|
|
|
|
workspaces:
|
|
- name: source
|
|
description: A workspace that contains the fetched git repository.
|
|
params:
|
|
- name: SQUASH_COUNT
|
|
type: string
|
|
description: |
|
|
Number of commits to squash in the branch.
|
|
default: "0"
|
|
|
|
- name: COMMIT_MSG
|
|
type: string
|
|
description: |
|
|
Commit message after the squash is done.
|
|
default: ""
|
|
|
|
- name: GIT_USER_NAME
|
|
type: string
|
|
description: |
|
|
Git user name to use for rebase.
|
|
|
|
- name: GIT_USER_EMAIL
|
|
type: string
|
|
description: |
|
|
Git user email to use for rebase.
|
|
|
|
- name: PULL_REMOTE_NAME
|
|
type: string
|
|
description: |
|
|
Git remote name from which we have to pull and rebase.
|
|
default: origin
|
|
|
|
- name: PULL_REMOTE_URL
|
|
type: string
|
|
description: |
|
|
Git remote URL from which we have to pull and rebase.
|
|
|
|
- name: PULL_BRANCH_NAME
|
|
type: string
|
|
description: |
|
|
Git branch name from which we have to pull and rebase.
|
|
|
|
- name: PUSH_REMOTE_NAME
|
|
type: string
|
|
description: |
|
|
Git remote name to push after rebase.
|
|
default: origin
|
|
|
|
- name: PUSH_REMOTE_URL
|
|
type: string
|
|
description: |
|
|
Git remote URL to push after rebase.
|
|
|
|
- name: PUSH_BRANCH_NAME
|
|
type: string
|
|
description: |
|
|
Git branch to push after rebase.
|
|
results:
|
|
- name: commit
|
|
description: The precise commit SHA after the rebase.
|
|
steps:
|
|
- name: rebase
|
|
workingDir: $(workspaces.source.path)
|
|
image: docker.io/alpine/git:v2.26.2@sha256:23618034b0be9205d9cc0846eb711b12ba4c9b468efdd8a59aac1d7b1a23363f #tag: v2.26.2
|
|
script: |
|
|
|
|
# Setting up the config for the git.
|
|
git config user.email "$(params.GIT_USER_EMAIL)"
|
|
git config user.name "$(params.GIT_USER_NAME)"
|
|
|
|
# Squashing the commits if required.
|
|
if [ "$(params.SQUASH_COUNT)" != 0 ] ; then
|
|
|
|
git reset --soft HEAD~$(params.SQUASH_COUNT)
|
|
git add .
|
|
git commit -m "$(params.COMMIT_MSG)"
|
|
|
|
fi
|
|
|
|
# Checking if remote is already set up or not.
|
|
git ls-remote --exit-code $(params.PULL_REMOTE_NAME)
|
|
|
|
# Setting up remote url for pull.
|
|
if test $? != 0; then
|
|
git remote add $(params.PULL_REMOTE_NAME) $(params.PULL_REMOTE_URL)
|
|
fi
|
|
|
|
# Pull and rebase
|
|
git pull --rebase $(params.PULL_REMOTE_NAME) $(params.PULL_BRANCH_NAME)
|
|
|
|
# Checking if remote is already set up or not.
|
|
git ls-remote --exit-code $(params.PUSH_REMOTE_NAME)
|
|
|
|
# Setting up remote url for push.
|
|
if test $? != 0; then
|
|
git remote add $(params.PUSH_REMOTE_NAME) $(params.PUSH_REMOTE_URL)
|
|
fi
|
|
|
|
# Force push after the rebase.
|
|
git push $(params.PUSH_REMOTE_NAME) $(params.PUSH_BRANCH_NAME) -f
|
|
|
|
RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')"
|
|
|
|
# Make sure we don't add a trailing newline to the result!
|
|
echo -n "$RESULT_SHA" > $(results.commit.path)
|