I am trying to achieve searching for bug fixes available on certain code repository. All I have is individual fix's code . I need to come up with an executable which can parse the entire file and can establish whether the fix is available or not based on comparison of fix's code in entire file the fix is intended. I need some suggestions algorithm to implement this pattern matching exercise which would be conditional in nature.
-
patch --dry-run gives an error if the fix is already applied or if it doesn't match the file.stark– stark2014-01-20 19:14:25 +00:00Commented Jan 20, 2014 at 19:14
-
Does patch --dry-run is intelligent enough to identify the block in entire file even if the lines are little moved . I meant to say someone might have touched file and have inserted some lines above or below which makes line numbers irrelevantpavan– pavan2014-01-20 19:31:36 +00:00Commented Jan 20, 2014 at 19:31
-
If it uses a context diff it will find it.stark– stark2014-01-20 19:50:24 +00:00Commented Jan 20, 2014 at 19:50
-
Thanks stark Let me find out if it fits my need and will leave feedbackpavan– pavan2014-01-20 19:54:58 +00:00Commented Jan 20, 2014 at 19:54
Add a comment
|
1 Answer
Given the fix, I assume you can characterize it as a delta: the programmer made this change in that place/text in a file. (If you don't have that, you can get it from diff-like tools applied to the before-and-after files (see my Bio for a smart one).
Then you want to hunt for that text. You can do this with a regular expression probably fairly well, at least if the change is significant in size.
You're likely to have to show the matches to the user to vet them, since the search/match process is heuristic.
2 Comments
pavan
Thanks Baxter As the patches are available in git I have information on diff. I was trying to achieve this automated as User may not be involved . I wish to break them by delimiters and do a recursive search on file but needed an algorithm to implement.
Ira Baxter
What was wrong with "apply regexp to string representing file content"?