-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-repo.ps1
39 lines (32 loc) · 1.08 KB
/
update-repo.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env pwsh
#Requires -Version 3
#========================================
# NAME : update-repo.pwsh
# LANGUAGE : PowerShell (Core)
# PURPOSE : From a root path, update (git pull) all subfolders / repositories
# # https://gist.githubusercontent.com/douglas/1287372/raw/46f810306802099024833ea71b1af2d806561a16/update_git_repos.sh
#========================================
[CmdletBinding()]
param ($RootFolder)
# store the current dir
CUR_DIR=$(pwd)
if ($RootFolder) {
echo "Root: '$RootFolder' set by parameter"
} else {
$RootFolder="$HOME/repo"
echo 'No repo specified by parameter. Using ~/repo'
}
# Go to repository root
cd $RootFolder
# Let the person running the script know what's going on.
'Pulling all repositories...'
# Find all git repositories and update it to the main latest revision
$RepoList = Get-ChildItem -Path ~/repo/*/.git/ -Recurse -Force | Select-Object -ExpandProperty FullName | Split-Path -parent
$RepoList | ForEach-Object -Process {
cd $PSItem
pwd
git pull origin main
}
# lets get back to the CUR_DIR
cd $CUR_DIR
' Complete!'