Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 7624f66

Browse files
Add ExcludeFilenames config (#17)
* Add ExcludeFilenames config * Bump version * Apply suggestions from code review Co-authored-by: Brian Buchalter <brian.buchalter@gusto.com> Co-authored-by: Brian Buchalter <brian.buchalter@gusto.com>
1 parent 55fc89b commit 7624f66

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

committer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
)
99

10-
const VERSION = "0.1.6"
10+
const VERSION = "0.1.7"
1111

1212
func main() {
1313
version := flag.Bool("version", false, "Display version")

configure.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash -ex
22

3-
VERSION="0.1.6"
3+
VERSION="0.1.7"
44
GIT_PRE_COMMIT_HOOK=".git/hooks/pre-commit"
55
COMMITTER_YML="committer.yml"
66
COMMITTER_LOCATION="/usr/local/bin/committer"

core/task.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
)
99

1010
type Task struct {
11-
Name string
12-
Command string
13-
Files string
14-
Fix struct {
11+
Name string
12+
Command string
13+
Files string
14+
ExcludeFilenames bool
15+
Fix struct {
1516
Command string
1617
Output string
1718
Autostage bool
@@ -112,7 +113,7 @@ func (task Task) prepareCommand(fix bool) []string {
112113

113114
// Feed in changed files if we are running with --changed
114115
relevantChangedFilesList := task.relevantChangedFiles(changedFilesList)
115-
if len(relevantChangedFilesList) > 0 {
116+
if !task.ExcludeFilenames && len(relevantChangedFilesList) > 0 {
116117
cmdStr += " " + strings.Join(relevantChangedFilesList, " ")
117118
}
118119

core/task_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ func TestPrepareCommand(t *testing.T) {
5151
)
5252
}
5353

54+
func TestPrepareCommandWithExcludeFilenames(t *testing.T) {
55+
origChangedFiles := changedFilesList
56+
changedFilesList = []string{"one.rb", "two.js", "three.txt"}
57+
defer func() { changedFilesList = origChangedFiles }()
58+
59+
var task Task
60+
task.Command = "run-task"
61+
task.Files = ".txt"
62+
task.ExcludeFilenames = true
63+
64+
assert.Equal(
65+
t,
66+
[]string{"run-task"},
67+
task.prepareCommand(false),
68+
"It correctly passes no file names",
69+
)
70+
}
71+
5472
func TestPrepareFixedOutput(t *testing.T) {
5573
var task Task
5674
task.Fix.Output = "Fixed:"

0 commit comments

Comments
 (0)