How can I perform a git clone operation using Cake

Is it possible to clone a git repository using Cake script? If so, how can this be done?

+5
source share
1 answer

A large number of git operations can be performed using Cake.Git Addin . You can usually find examples of how to use the aliases provided by this addin here , however these examples do not yet exist.

In the interim, below are examples of how each of the four GitClone aliases can be used.

NOTE. . For the purpose of this answer, we will use the Cake git repository on GitHub

GitClone (string, directory)

#addin nuget:?package=Cake.Git Task("Git-Clone") .Does(() => { GitClone("https://github.com/cake-build/cake.git", "c:/temp/cake"); }); RunTarget("Git-Clone"); 

GitClone (string, DirectoryPath, GitCloneSettings)

 #addin nuget:?package=Cake.Git Task("Git-Clone") .Does(() => { GitClone("https://github.com/cake-build/cake.git", "c:/temp/cake", new GitCloneSettings{ BranchName = "main" }); }); RunTarget("Git-Clone"); 

GitClone (line, directory, line, line)

NOTE. This alias does not seem to create an output directory. As a result, EnsureDirectoryExists are used to verify that it exists.

 #addin nuget:?package=Cake.Git Task("Git-Clone") .Does(() => { EnsureDirectoryExists("c:/temp/cake"); GitClone("https://github.com/cake-build/cake.git", "c:/temp/cake", "username", "password"); }); RunTarget("Git-Clone"); 

GitClone (string, DirectoryPath, string, string, GitCloneSettings)

NOTE. This alias does not seem to create an output directory. As a result, EnsureDirectoryExists are used to verify that it exists.

 #addin nuget:?package=Cake.Git Task("Git-Clone") .Does(() => { EnsureDirectoryExists("c:/temp/cake"); GitClone("https://github.com/cake-build/cake.git", "c:/temp/cake", "username", "password", new GitCloneSettings{ BranchName = "main" }); }); RunTarget("Git-Clone"); 
+5
source

Source: https://habr.com/ru/post/1261016/


All Articles