Archive

Posts Tagged ‘script’

Sourcetree git diff script

August 4th, 2015 No comments

Git is great but it’s not always easy to know which files were changed between commits. I don’t want to deploy all files with each release so I wrote a small script that I use as a custom action in Sourcetree. It’s a batch script that takes 3 parameters:

  • the local path of the repository
  • hash of selected commit #1
  • hash of selected commit #2

sourcetree_git_diff_custom_action01

Batch script is added below, you’ll just need to modify the path to your local git.exe file
it contains a fix for windows users to replace the forward slash of git diff by a backslash

@echo off
setlocal EnableDelayedExpansion

C:\Users\<myusername>\AppData\Local\Atlassian\SourceTree\git_local\bin\git.exe diff --name-only %2 %3 > "C:\temp\a.txt"

mkdir C:\temp\%2
for /F "tokens=*" %%b in (c:\temp\a.txt) do (

set "lineString=%%b"
set "to_replace=/"
for %%f in ("!to_replace!") do set "str2=!lineString:%%~f=\!"
REM echo "%1\!str2!"

ECHO Processing "%1\!str2!" ....

xcopy "%1\!str2!" "C:\temp\%2\!str2!*" /s /i /Y
)

endlocal

Select the 2 commits and execute the custom action. The modified files will be copied under C:\temp\<hash1>\

sourcetree_git_diff_custom_action02

Powershell: check installed version

August 12th, 2010 No comments

It might be usefull to know which version of Powershell is installed on your server / desktop.
Open a dos-prompt and then open a PowerShell session. There are 3 ways to check the installed version

Method 1

$Host.Version

Method 2

get-host


Method 3 (works only with v2)

$PSVersionTable

Categories: Powershell, Scripts Tags: , ,

Script to add DNS suffixes to a NIC

August 11th, 2010 2 comments

Adjust the array with your dns suffixes and save as a .VBS file

DNSSuffixSearchOrder = Array(“MYDNS1.COM”, “MYDNS2.COM”)

Set WMI = GetObject(“WinMgmts://”)

Set adapter = GetObject(“winmgmts:Win32_NetworkAdapterConfiguration”)

adapter.SetDNSSuffixSearchOrder (DNSSuffixSearchOrder)

Archive post Jan 7th, 2007

Categories: Scripts, VBScript, Windows Tags: ,