Skip to content

Commit

Permalink
Merge pull request #9 from cruise-automation/collin/filetree_cond_cur…
Browse files Browse the repository at this point in the history
…rent_path

only include current path if .new file written
  • Loading branch information
Collin Mulliner committed Nov 18, 2019
2 parents ba18427 + cf7ec4e commit c1dfcd7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/analyzer/filetree/filetree.go
Expand Up @@ -232,11 +232,13 @@ func (state *fileTreeType) Finalize() string {
}
}

treeUpdated := false
if len(added) > 0 || len(removed) > 0 || (len(changed) > 0 && state.config.CheckPermsOwnerChange) {
err := state.saveTree()
if err != nil {
panic("saveTree failed")
}
treeUpdated = true
}

for _, fi := range added {
Expand All @@ -259,9 +261,14 @@ func (state *fileTreeType) Finalize() string {
if state.config.OldTreeFilePath != "" {
type reportData struct {
OldFileTreePath string `json:"old_file_tree_path"`
CurrentFileTreePath string `json:"current_file_tree_path"`
CurrentFileTreePath string `json:"current_file_tree_path,omitempty"`
}
data := reportData{state.config.OldTreeFilePath, state.config.OldTreeFilePath + newFileTreeExt}
newPath := ""
if treeUpdated {
newPath = state.config.OldTreeFilePath + newFileTreeExt
}

data := reportData{state.config.OldTreeFilePath, newPath}
jdata, _ := json.Marshal(&data)
return string(jdata)
}
Expand Down

0 comments on commit c1dfcd7

Please sign in to comment.