@@ -18,6 +18,7 @@ var updateExternalsCmd = &cobra.Command{
1818 Short : "Downloads and updates git externals like plugins, etc" ,
1919 Long : `Downloads and updates git externals like plugins, etc` ,
2020 Run : func (cmd * cobra.Command , args []string ) {
21+ // TODO: if files get deleted in upstream
2122 // issue with unmarshalling the yaml config https://github.com/spf13/viper/issues/338
2223 // type configPathAttributes struct {
2324 // url string `mapstructure:"url"`
@@ -60,10 +61,36 @@ var updateExternalsCmd = &cobra.Command{
6061 if externalsPaths != nil {
6162 // clone externals repo
6263 if utils .IsGitRepoDir (repoPath ) {
64+ // Get current commit id
65+ currentCommitID , _ := utils .GitCommand (false ,
66+ repoPath ,
67+ "rev-parse" ,
68+ "HEAD" ,
69+ )
70+
6371 isUpToDate , _ = utils .GitCommand (false ,
6472 repoPath ,
6573 "pull" ,
6674 )
75+
76+ // Get files deleted between previous commit to latest commit
77+ deletedFiles , _ := utils .GitCommand (false ,
78+ repoPath ,
79+ "show" ,
80+ utils .RemoveRunes (string (currentCommitID ))+ "..HEAD" ,
81+ "--diff-filter=D" ,
82+ "--name-only" ,
83+ "--no-commit-id" ,
84+ )
85+
86+ deletedFilesList := strings .Fields (string (deletedFiles ))
87+
88+ if len (deletedFilesList ) >= 0 {
89+ for _ , file := range deletedFilesList {
90+ os .Remove (utils .HomeDir + "/" + externalKey + "/" + file )
91+ }
92+ }
93+
6794 } else {
6895 utils .GitCommand (true ,
6996 "" ,
0 commit comments