@@ -137,6 +137,7 @@ def vendor(
137
137
os .path .dirname (self .yaml_file ),
138
138
self .manifest ["vendoring" ]["vendor-directory" ],
139
139
)
140
+ self .run_vendoring_actions (revision , "post-patch-actions" )
140
141
return
141
142
142
143
# ==========================================================
@@ -272,7 +273,7 @@ def process_regular_or_individual(
272
273
self .logInfo ({}, "Skipping fetching upstream source." )
273
274
274
275
self .logInfo ({}, "Checking for update actions" )
275
- self .update_files (new_revision )
276
+ self .run_vendoring_actions (new_revision , "update-actions" )
276
277
277
278
if self .patch_mode == "check" :
278
279
self .import_local_patches (
@@ -698,14 +699,14 @@ def spurious_check(self, revision, ignore_modified):
698
699
"Version '{rev}' has changed {num} files." ,
699
700
)
700
701
701
- def update_files (self , revision ):
702
- if "update-actions" not in self .manifest ["vendoring" ]:
702
+ def run_vendoring_actions (self , revision , actions_type = "update-actions" ):
703
+ if actions_type not in self .manifest ["vendoring" ]:
703
704
return
704
705
705
- for update in self .manifest ["vendoring" ]["update-actions" ]:
706
- if update ["action" ] == "copy-file" :
707
- src = self .get_full_path (update ["from" ])
708
- dst = self .get_full_path (update ["to" ])
706
+ for action in self .manifest ["vendoring" ][actions_type ]:
707
+ if action ["action" ] == "copy-file" :
708
+ src = self .get_full_path (action ["from" ])
709
+ dst = self .get_full_path (action ["to" ])
709
710
710
711
self .logInfo (
711
712
{"s" : src , "d" : dst }, "action: copy-file src: {s} dst: {d}"
@@ -715,24 +716,24 @@ def update_files(self, revision):
715
716
contents = f .read ()
716
717
with open (dst , "w" ) as f :
717
718
f .write (contents )
718
- elif update ["action" ] == "vcs-add-remove-files" :
719
- directory = self .get_full_path (update ["path" ])
719
+ elif action ["action" ] == "vcs-add-remove-files" :
720
+ directory = self .get_full_path (action ["path" ])
720
721
721
722
self .logInfo ({"d" : directory }, "action: vcs-add-remove-files dir: {d}" )
722
723
723
724
self .repository .add_remove_files (directory )
724
- elif update ["action" ] == "move-file" :
725
- src = self .get_full_path (update ["from" ])
726
- dst = self .get_full_path (update ["to" ])
725
+ elif action ["action" ] == "move-file" :
726
+ src = self .get_full_path (action ["from" ])
727
+ dst = self .get_full_path (action ["to" ])
727
728
728
729
self .logInfo (
729
730
{"s" : src , "d" : dst }, "action: move-file src: {s} dst: {d}"
730
731
)
731
732
732
733
shutil .move (src , dst )
733
- elif update ["action" ] == "move-dir" :
734
- src = self .get_full_path (update ["from" ])
735
- dst = self .get_full_path (update ["to" ])
734
+ elif action ["action" ] == "move-dir" :
735
+ src = self .get_full_path (action ["from" ])
736
+ dst = self .get_full_path (action ["to" ])
736
737
737
738
self .logInfo (
738
739
{"src" : src , "dst" : dst }, "action: move-dir src: {src} dst: {dst}"
@@ -761,32 +762,32 @@ def copy_tree(src, dst):
761
762
copy_tree (src , dst )
762
763
shutil .rmtree (src )
763
764
764
- elif update ["action" ] in ["replace-in-file" , "replace-in-file-regex" ]:
765
- file = self .get_full_path (update ["file" ])
765
+ elif action ["action" ] in ["replace-in-file" , "replace-in-file-regex" ]:
766
+ file = self .get_full_path (action ["file" ])
766
767
767
768
self .logInfo ({"file" : file }, "action: replace-in-file file: {file}" )
768
769
769
- replacement = update ["with" ].replace ("{revision}" , revision )
770
+ replacement = action ["with" ].replace ("{revision}" , revision )
770
771
_replace_in_file (
771
772
file ,
772
- update ["pattern" ],
773
+ action ["pattern" ],
773
774
replacement ,
774
- regex = update ["action" ] == "replace-in-file-regex" ,
775
+ regex = action ["action" ] == "replace-in-file-regex" ,
775
776
)
776
- elif update ["action" ] == "delete-path" :
777
- path = self .get_full_path (update ["path" ])
777
+ elif action ["action" ] == "delete-path" :
778
+ path = self .get_full_path (action ["path" ])
778
779
self .logInfo ({"path" : path }, "action: delete-path path: {path}" )
779
780
mozfile .remove (path )
780
- elif update ["action" ] in ["run-script" , "run-command" ]:
781
- if update ["action" ] == "run-script" :
782
- command = self .get_full_path (update ["script" ], support_cwd = True )
781
+ elif action ["action" ] in ["run-script" , "run-command" ]:
782
+ if action ["action" ] == "run-script" :
783
+ command = self .get_full_path (action ["script" ], support_cwd = True )
783
784
else :
784
- command = update ["command" ]
785
+ command = action ["command" ]
785
786
786
- run_dir = self .get_full_path (update ["cwd" ], support_cwd = True )
787
+ run_dir = self .get_full_path (action ["cwd" ], support_cwd = True )
787
788
788
789
args = []
789
- for a in update .get ("args" , []):
790
+ for a in action .get ("args" , []):
790
791
if a == "{revision}" :
791
792
args .append (revision )
792
793
elif any (
@@ -808,7 +809,7 @@ def copy_tree(src, dst):
808
809
"command" : command ,
809
810
"run_dir" : run_dir ,
810
811
"args" : args ,
811
- "type" : update ["action" ],
812
+ "type" : action ["action" ],
812
813
},
813
814
"action: {type} command: {command} working dir: {run_dir} args: {args}" ,
814
815
)
0 commit comments