Skip to content

Commit

Permalink
chore: move limits to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Apr 8, 2024
1 parent baef211 commit 64a5de4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
23 changes: 23 additions & 0 deletions internal/system/limits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package system

import "runtime"

const (
// https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
// https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation
// https://unix.stackexchange.com/a/120652
maxCommandLengthDarwin = 260000 // 262144
maxCommandLengthWindows = 7000 // 8191, but see issues#655
maxCommandLengthLinux = 130000 // 131072
)

func MaxCmdLen() int {
switch runtime.GOOS {
case "windows":
return maxCommandLengthWindows
case "darwin":
return maxCommandLengthDarwin
default:
return maxCommandLengthLinux
}
}
21 changes: 0 additions & 21 deletions internal/system/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ package system
import (
"os"
"os/exec"
"runtime"

"github.com/evilmartians/lefthook/internal/log"
)

const (
// https://serverfault.com/questions/69430/what-is-the-maximum-length-of-a-command-line-in-mac-os-x
// https://support.microsoft.com/en-us/help/830473/command-prompt-cmd-exe-command-line-string-limitation
// https://unix.stackexchange.com/a/120652
maxCommandLengthDarwin = 260000 // 262144
maxCommandLengthWindows = 7000 // 8191, but see issues#655
maxCommandLengthLinux = 130000 // 131072
)

type Executor struct{}

// Execute executes git command with LEFTHOOK=0 in order
Expand All @@ -41,14 +31,3 @@ func (e Executor) Execute(args []string, root string) (string, error) {

return string(out), nil
}

func MaxCmdLen() int {
switch runtime.GOOS {
case "windows":
return maxCommandLengthWindows
case "darwin":
return maxCommandLengthDarwin
default:
return maxCommandLengthLinux
}
}

0 comments on commit 64a5de4

Please sign in to comment.