Skip to content

tektoncd-catalog/git-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-clone

Git Clone Task for Tekton

This repository contains the git-clone Task for Tekton Pipelines, providing Git repository cloning capabilities.

Recent Fixes

Git Remote Origin Error Fix

Problem: The git-clone task was logging an error message:

Error running git [remote get-url origin]: exit status 2
error: No such remote 'origin'

This occurred because the original code tried to check if the "origin" remote existed using git remote get-url origin, which fails on fresh repositories where no remotes exist yet.

Solution: The code now:

  1. Uses git remote to safely list existing remotes (this command never fails)
  2. Checks if "origin" is in the list of existing remotes
  3. If the remote exists, updates its URL using git remote set-url
  4. If the remote doesn't exist, adds it using git remote add

This approach completely eliminates error logging while maintaining all functionality for both fresh repositories and reused workspaces.

Files Modified:

  • image/git-init/git/git.go - Updated the fetchOrigin function with robust remote handling

Benefits:

  • Eliminates spurious error messages in pipeline logs
  • Works correctly with both fresh repositories and reused workspaces
  • Maintains backward compatibility
  • Provides cleaner, more reliable git operations

Building

To build the updated git-init binary:

cd image/git-init
ko build --local .

Testing

The fix handles these scenarios correctly:

  • Fresh repository: git remote add origin <URL> succeeds ✅
  • Reused workspace with same URL: git remote add fails → git remote set-url succeeds ✅
  • Reused workspace with different URL: git remote add fails → git remote set-url updates URL ✅
  • Invalid configuration: Both operations fail → reports actual error ✅

Image Reference:

ttl.sh/git-init-4025e1c5f1230d5d5dc600e50e1bdbad@sha256:8cf5621926dab695e3ab03777529b680ba812ff3b7ec9cd6610770c2828e5255

Where to use it:

Let me check the

About

Tekton official git-clone Catalog

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

 
 
 

Contributors 6

Languages