Skip to content

Commit

Permalink
fix parameter order
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonis, Matthias authored and Simonis, Matthias committed Mar 1, 2024
1 parent aae07d3 commit 590ca78
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions golang/vaas/cmd/git-scan/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ import (

func main() {
if len(os.Args) < 3 {
log.Fatal("need 2 parameter: targetBranch, remote")
log.Fatal("need 2 parameter: remote, targetBranch")
}

targetBranch := os.Args[1]
if targetBranch == "" {
log.Fatal("no targetBranch set")
remote := os.Args[1]
if remote == "" {
log.Fatal("no remote set")
}
log.Println("targetBranch: ", targetBranch)
remote := os.Args[2]
log.Println("remote:", remote)
targetBranch := os.Args[2]
if targetBranch == "" {
log.Fatal("no remote set")
log.Fatal("no targetBranch set")
}
log.Println("remote: ", remote)
log.Println("targetBranch:", targetBranch)

clientID, exists := os.LookupEnv("VAAS_CLIENT_ID")
if !exists {
Expand All @@ -50,22 +50,22 @@ func main() {
gitRevParseCommand := exec.Command("git", "rev-parse", "--show-toplevel")
rootDirectoryBytes, err := gitRevParseCommand.CombinedOutput()
if err != nil {
log.Fatal("git rev-parse: ", err, string(rootDirectoryBytes))
log.Fatal("git rev-parse: ", err, " ", string(rootDirectoryBytes))
}
rootDirectory := strings.Split(strings.ReplaceAll(string(rootDirectoryBytes), "\r\n", "\n"), "\n")[0]
log.Println("repository root directory: ", rootDirectory)

fetchBytesCommand := exec.Command("git", "fetch", remote, targetBranch)
fetchBytes, err := fetchBytesCommand.CombinedOutput()
if err != nil {
log.Fatal("git fetch ", err, string(fetchBytes))
log.Fatal("git fetch ", err, " ", string(fetchBytes))
}
log.Println("fetch result: ", string(fetchBytes))

gitDiffCommand := exec.Command("git", "diff", "--name-only", remote+"/"+targetBranch)
diffBytes, err := gitDiffCommand.CombinedOutput()
if err != nil {
log.Fatal("git diff ", err, string(diffBytes))
log.Fatal("git diff ", err, " ", string(diffBytes))
}
files := strings.Split(strings.ReplaceAll(string(diffBytes), "\r\n", "\n"), "\n")
if len(files) < 1 {
Expand Down

0 comments on commit 590ca78

Please sign in to comment.