0

I have this Powershell script which iterates through this folder's directories and runs git log.

However I cannot figure out how to get the $author parameter through to the git command.

Param(
  [string]$author,
  [string]$since
)
Get-ChildItem | ? { $_.PSIsContainer } | % { Push-Location $_.FullName; Write-Host "--" (Get-Location);`
git --no-pager log --author=$author --since='1 friday ago' --until='now' --format='%Cgreen%cr%Creset %s%Creset' --graph --decorate;`
Pop-Location }
6
  • What do you get when you invoke the script? Commented Apr 29, 2015 at 10:36
  • The list of folder names... I'm looking into it being a quotes issue now. Commented Apr 29, 2015 at 10:55
  • Yes, you should definitely pass the $author argument in quotes. Commented Apr 29, 2015 at 10:56
  • If I don't pass the command then I get all commits which leads suggests the $author is actually getting though Commented Apr 29, 2015 at 10:56
  • Yes I was passing it through quoted since the start. I'm checking out the git command to see if putting quotes like : --author="$author" Commented Apr 29, 2015 at 10:58

1 Answer 1

1

Given this script:

# Log.ps1
Param(
    [string]$author
)

Get-ChildItem -Directory | % { Push-Location $_.FullName; git --no-pager log --author=$author; Pop-Location }

Invoking it like this yields the correct result:

.\Log.ps1 "SomeAuthor"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.