forked from nazzzzz/rules_gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 23 commits.
# This is the 1st commit message: app name first # This is the commit message nazzzzz#2: clean up file # This is the commit message nazzzzz#3: fix reference to proto package # This is the commit message fasterci#4: better parse # This is the commit message fasterci#5: fix again # This is the commit message fasterci#6: fix again # This is the commit message fasterci#7: fix again # This is the commit message fasterci#8: fix again # This is the commit message fasterci#9: fix again # This is the commit message fasterci#10: fix again # This is the commit message fasterci#11: add debug statements for seeing if branch is dirty # This is the commit message fasterci#12: fix again # This is the commit message fasterci#13: fix again # This is the commit message fasterci#14: fix again # This is the commit message fasterci#15: fix again # This is the commit message fasterci#16: fix again # This is the commit message fasterci#17: fix again # This is the commit message fasterci#18: fix again # This is the commit message fasterci#19: fix again # This is the commit message fasterci#20: fix again # This is the commit message fasterci#21: fix again # This is the commit message fasterci#22: fix again # This is the commit message fasterci#23: fix again
- Loading branch information
Showing
367 changed files
with
38,362 additions
and
1,344 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,11 @@ import ( | |
"os" | ||
oe "os/exec" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/fasterci/rules_gitops/gitops/exec" | ||
) | ||
|
||
var ( | ||
git = "git" | ||
) | ||
|
||
// Clone clones a repository. Pass the full repository name, such as | ||
// "https://[email protected]/scm/tm/repo.git" as the repo. | ||
// Cloned directory will be clean of local changes with primaryBranch branch checked out. | ||
|
@@ -120,3 +117,33 @@ func (r *Repo) Push(branches []string) { | |
args := append([]string{"push", "origin", "-f", "--set-upstream"}, branches...) | ||
exec.Mustex(r.Dir, "git", args...) | ||
} | ||
|
||
func (r *Repo) GetModifiedFiles() ([]string, error) { | ||
cmd := oe.Command("git", "status", "--porcelain") | ||
cmd.Dir = r.Dir | ||
output, err := cmd.CombinedOutput() | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get modified files: %w", err) | ||
} | ||
|
||
if len(output) == 0 { | ||
return []string{}, nil | ||
} | ||
|
||
// Split output into lines and process each line | ||
lines := strings.Split(strings.TrimSpace(string(output)), "\n") | ||
files := make([]string, 0, len(lines)) | ||
|
||
for _, line := range lines { | ||
if len(line) > 3 { | ||
// git status --porcelain output format is "XY filename" | ||
// where X and Y are status codes | ||
// We just want the filename part | ||
file := strings.TrimSpace(line[2:]) | ||
files = append(files, file) | ||
log.Printf("Modified file: %s", file) | ||
} | ||
} | ||
|
||
return files, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.