|
|
|
@ -630,6 +630,8 @@ echo "script: $0"
|
|
|
|
|
echo "pwd: $(pwd)" |
|
|
|
|
echo "scriptdir: $scriptdir" |
|
|
|
|
echo "scriptpath: $scriptpath" |
|
|
|
|
scriptdir=$(realpath $scriptdir) |
|
|
|
|
scriptpath=$(realpath $scriptpath) |
|
|
|
|
|
|
|
|
|
basename=$(basename "$scriptpath") |
|
|
|
|
scriptroot="${basename%.*}" #e.g "getpunk" |
|
|
|
@ -648,13 +650,15 @@ if [[ "$launchdir" != "$scriptdir" ]]; then
|
|
|
|
|
else |
|
|
|
|
punkfolder=$scriptdir |
|
|
|
|
fi |
|
|
|
|
cd $punkfolder |
|
|
|
|
|
|
|
|
|
contentcount=$(ls -A | wc -l) |
|
|
|
|
effectively_empty=0 |
|
|
|
|
if [ $contentcount == 0 ]; then |
|
|
|
|
effectively_empty=1 |
|
|
|
|
elif [[ ("$punkfolder" == "$scriptfolder") && ("$contentcount" -lt 10) ]]; then |
|
|
|
|
elif [[ ("$punkfolder" == "$scriptdir") && ("$contentcount" -lt 10) ]]; then |
|
|
|
|
#treat as empty if we have only a few files matching script root name |
|
|
|
|
count_scriptlike=$(ls ${basename}.* | wc -l) |
|
|
|
|
count_scriptlike=$(ls ${scriptroot}.* | wc -l) |
|
|
|
|
if [ "$count_scriptlike" -eq $contentcount ]; then |
|
|
|
|
effectively_empty=1 |
|
|
|
|
fi |
|
|
|
@ -677,13 +681,18 @@ if [ "$effectively_empty" -ne 1 ]; then
|
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
cd $punkfolder |
|
|
|
|
if ! [ -d "$punkfolder/.git" ]; then |
|
|
|
|
#set defaultbranch to master to suppress loud stderr 'hint' about initial branch name. |
|
|
|
|
git -c init.DefaultBranch=master init |
|
|
|
|
git remote add origin $git_upstream |
|
|
|
|
fi |
|
|
|
|
git fetch origin |
|
|
|
|
if [[ "$punkfolder" == "$scriptdir" ]]; then |
|
|
|
|
if [ -f $scriptroot.cmd ]; then |
|
|
|
|
cp -f $scriptroot.cmd $scriptroot.cmd.lastrun |
|
|
|
|
rm $scriptroot.cmd |
|
|
|
|
fi |
|
|
|
|
fi |
|
|
|
|
git pull $git_upstream master |
|
|
|
|
git branch --set-upstream-to=origin/master master |
|
|
|
|
|
|
|
|
@ -909,6 +918,7 @@ $git_upstream = "https://www.gitea1.intx.com.au/jn/punkshell"
|
|
|
|
|
$launchdir = Get-Location #store original CWD |
|
|
|
|
$scriptfolder = Resolve-Path (Split-Path -Path $PSCommandPath -Parent) |
|
|
|
|
$punkfolder = "" |
|
|
|
|
$scriptroot = "$([System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath))" |
|
|
|
|
|
|
|
|
|
if (-not (Get-Command "git" -ErrorAction SilentlyContinue)) { |
|
|
|
|
Write-Host "The git command doesn't seem to be available. Will attempt to install using winget." |
|
|
|
@ -974,7 +984,7 @@ if ($contentcount -eq 0) {
|
|
|
|
|
$effectively_empty = 1 |
|
|
|
|
} elseif ($punkfolder -eq $scriptfolder -and $contentcount -lt 10) { |
|
|
|
|
#treat as empty if we have only a few files matching script root name |
|
|
|
|
$scriptlike = get-childitem -Path $punkfolder | Where-Object {$_.name -like "$([System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath)).*"} |
|
|
|
|
$scriptlike = get-childitem -Path $punkfolder | Where-Object {$_.name -like "${scriptroot}.*"} |
|
|
|
|
if ($scriptlike.Count -eq $contentcount) { |
|
|
|
|
$effectively_empty = 1 |
|
|
|
|
} |
|
|
|
@ -1005,6 +1015,11 @@ if (-not(Test-Path -Path (Join-Path -Path $punkfolder -ChildPath ".git") -PathTy
|
|
|
|
|
git remote add origin $git_upstream |
|
|
|
|
} |
|
|
|
|
git fetch origin |
|
|
|
|
if (($launchdir.Path) -eq ($scriptfolder.Path)) { |
|
|
|
|
if (Test-Path -Path "${scriptroot}.cmd") { |
|
|
|
|
Rename-Item -Path "${scriptroot}.cmd" -NewName "${scriptroot}.cmd.lastrun" -Force |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
git pull $git_upstream master |
|
|
|
|
git branch --set-upstream-to=origin/master master |
|
|
|
|
|
|
|
|
|