revamped patch task to work with stages as well as inject files