Use PowerShell to check an xml file in the Git staging area -


i'm using git asp.net web site passwords stored in web.config file. keep getting committed, set configuration section encryption, connectionstrings section of file encrypted -- unless decrypt fool around it.

then prevent accidentally committing un-encrypted, wrote little powershell script local pre-commit hook invokes:

# verifies web.config's connectionstrings encrypted.  [xml]$config = get-content .\code\slicerweb\web.config if ($config.configuration.connectionstrings.encrypteddata) {     exit 0     } else {     write-output "connectionstrings section not encrypted."     exit 1     } 

and works fine, , enough. realize should check contents of file in index (staging area), rather current file on disk.

how can get-content of file exists in index?

you can use : prefix access objects in current index. should work

[xml]$config = git show :./code/slicerweb/web.config 

(backslashes in path not work here)


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -