diff --git a/install.ps1 b/install.ps1 index 5c4b1b1..4be7cda 100644 --- a/install.ps1 +++ b/install.ps1 @@ -727,7 +727,8 @@ function Apply-CustomFile() { [string] $otherCustomPath = "" ) - $local:gitDir = "${profilePath}\chrome\.git" + $local:leptonDir = "${profilePath}\chrome" + $local:gitDir = "${leptonDir}\.git" if ( Test-Path -Path "${customPath}" -PathType leaf ) { $global:customFileApplied = $true @@ -737,10 +738,10 @@ function Apply-CustomFile() { if ( "${customReset}" -eq $true ) { if ( "${targetPath}" -like "*user.js" ) { - Copy-Item -Path "${customFile}" -Destination "${targetPath}" -Force + Copy-Item -Path "${leptonDir}\user.js" -Destination "${targetPath}" -Force } else { - git --git-dir "${gitDir}" checkout HEAD -- "${targetPath}" + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout HEAD -- "${targetPath}" } } if ( "${customAppend}" -eq $true ) { @@ -875,26 +876,30 @@ function Install-Profile() { #** Update ********************************************************************* function Stash-File() { Param ( - [Parameter(Position=0)] - [string] $gitDir = ".git" + [Parameter(Mandatory=$true, Position=0)] + [string] $leptonDir, + [Parameter(Mandatory=$true, Position=1)] + [string] $gitDir ) - if ( "$(git --git-dir "${gitDir}" diff --stat)" -ne '' ) { - git --git-dir "${gitDir}" checkout stash + if ( "$(git --git-dir "${gitDir}" --work-tree "${leptonDir}" diff --stat)" -ne '' ) { + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout stash return $true } return $false } function Restore-File() { Param ( - [Parameter(Position=0)] - [string] $gitDir = ".git", - [Parameter(Position=1)] + [Parameter(Mandatory=$true, Position=0)] + [string] $leptonDir, + [Parameter(Mandatory=$true, Position=1)] + [string] $gitDir, + [Parameter(Position=2)] [switch] $gitDirty = $false ) if ( "${gitDirty}" -eq $true ) { - git --git-dir "${gitDir}" checkout stash pop --quiet + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout stash pop --quiet } } @@ -910,14 +915,15 @@ function Update-Profile() { $local:Branch = $LEPTONINFO["${section}"]["Branch"] $local:Path = $LEPTONINFO["${section}"]["Path"] - $local:LEPTONGITPATH="${Path}\chrome\.git" + $local:leptonDir = "${Path}\chrome" + $local:gitDir = "${leptonDir}\.git" if ( "${Type}" -eq "Git" ) { - $local:gitDirty = $(Stash-File "${LEPTONGITPATH}") + $local:gitDirty = $(Stash-File "${leptonDir}" "${gitDir}") - git --git-dir "${LEPTONGITPATH}" checkout "${Branch}" - git --git-dir "${LEPTONGITPATH}" pull --no-edit + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout "${Branch}" + git --git-dir "${gitDir}" --work-tree "${leptonDir}" pull --no-edit - Restore-File "${LEPTONGITPATH}" $gitDirty + Restore-File "${leptonDir}" "${gitDir}" $gitDirty } elseif ( "${Type}" -eq "Local" -or "${Type}" -eq "Release" ) { Check-ChromeExist @@ -929,11 +935,11 @@ function Update-Profile() { if ( "${Branch}" -eq $null ) { $Branch = "${leptonBranch}" } - git --git-dir "${LEPTONGITPATH}" checkout "${Branch}" + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout "${Branch}" if ( "${Type}" -eq "Release" ) { - $local:Ver=$(git --git-dir "${LEPTONINFOFILE}" describe --tags --abbrev=0) - git --git-dir "${LEPTONGITPATH}" checkout "tags/${Ver}" + $local:Ver=$(git --git-dir "${gitDir}" describe --tags --abbrev=0) + git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout "tags/${Ver}" } Clean-Lepton diff --git a/install.sh b/install.sh index 1897292..ad9823f 100755 --- a/install.sh +++ b/install.sh @@ -843,16 +843,18 @@ install_profile() { #** Update ********************************************************************* file_stash() { - local profilePath=$1 - if [[ $(git --git-dir "${profilePath}/.git" --work-tree "${profilePath}/chrome" diff --stat) != '' ]]; then - git --git-dir "${profilePath}/chrome/.git" --work-tree "${profilePath}/chrome" stash + local leptonDir=$1 + local gitDir=$2 + if [[ $(git --git-dir "${gitDir}" --work-tree "${leptonDir}" diff --stat) != '' ]]; then + git --git-dir "${gitDir}" --work-tree "${leptonDir}" stash fi } file_restore() { - local profilePath=$1 - local gitDirty=$2 + local leptonDir=$1 + local gitDir=$2 + local gitDirty=$3 if [ -n "${gitDirty}" ]; then - git --git-dir "${profilePath}/chrome/.git" --work-tree "${profilePath}/chrome" stash pop --quiet + git --git-dir "${gitDir}" --work-tree "${leptonDir}" stash pop --quiet fi } @@ -870,12 +872,12 @@ update_profile() { local leptonDir="${Path}/chrome" local gitDir="${leptonDir}/.git" if [ "${Type}" == "Git" ]; then - local gitDirty="$(file_stash ${gitDir})" + local gitDirty=$(file_stash "${leptonDir}" "${gitDir}") git --git-dir "${gitDir}" --work-tree "${leptonDir}" checkout "${Branch}" git --git-dir "${gitDir}" --work-tree "${leptonDir}" pull --no-edit - file_restore "${Path}" "${gitDirty}" + file_restore "${leptonDir}" "${gitDir}" "${gitDirty}" elif [ "${Type}" == "Local" ] || [ "${Type}" == "Release" ]; then check_chrome_exist clone_lepton