Complex WinMerge filters - otrs

I've just started a project involving a customized OTRS 3.1.
In this project we have two folders, the original kernel folder, and the custom kernel folder.
If a file is present on the custom kernel folder, then it overrides the original kernel folder file. Thus, updating the version of OTRS 3.1 to the most stable one, is just a matter of substituting the original kernel folder. But We have a problem: if a customized file is updated, the update is ignored, since our customization overrides the original one. So we need to detect those conflicts in order to apply the enhancements to our customized file manually.
So to achieve it I planned the next strategy. Let's assume I have the next file at the original kernel file:
print "Hello ";
print "World\n";
I want to customize it, changing World by "ACME", So I copy this file to the custom folder and change it to:
print "Hello ";
##- CUSTOM CODE
##- Date: 10/02/2014
##- By: Dave
##- Original code:
=pod
print "World\n";
=cut
##< Start custom code
print "ACME\n";
## end custom code >##
=pod and =cut are a block comment
Now let's imagine that to print the word Hello is detected as a risk, and they change the code of the file on a new stable version to:
print "Hi ";
print "World\n";
When applying the change to my original folder, I will not take profit of the security fix, since I have a custom file that still contains the Hello word. That said, I want to use WinMerge (or other tool that can achieve the same result) to detect my custom code tags so:
The lines starting by ##- are ignored.
The lines =pod and =cut are ignored.
The blocks between ##< and >## are ignored
Thus the first original file and my custom file will be identical after filtered, but after the update, it will detect the difference and allow me to merge the changes to my custom version.
I know how to create the filter for the lines starting by ##- or equal to =pod or =cut. But I don't know how to ignore a multiline block from the comparison.
Do you know how can I achieve what I want? If not with WinMerge, Is there any another tool that can help me automating this task?
Thank you very much in advance!

Related

Having a beamer_presentation and a pdf_book in the same Bookdown project

In my Bookdown project, I have both a bookdown::pdf_book and a beamer_presentation specificed in the _output.yml. (Why? Here is an example, and here is the explanation.)
The problem is that pdf_book seems to respect the output_dir specified in _bookdown.yml, but not the beamer_presentation. Thus, when hitting the Build Book button, the presentation won't get into the docs directory, it'll appear in the base directory.
Is there any way to make beamer_presentation respect the output_dir specification?
(Also, it'll mean that something has to be done with the filenames, as by default the the names would be the same.)
EDIT: I realized that using bookdown::beamer_presentation2 instead of beamer_presentation will solve the problem, as it'll respect the output_dir. But I'd call it a partial answer, as my fears in the last sentence realized: this will simply overwrite the pdf_book (as they'll indeed have the same name), so it is still not really working...
Yes, you need to use bookdown::beamer_presentation2, which will respect the output_dir setting in _bookdown.yml.
Regarding to your second problem (two formats having the same output filename), there isn't a nice solution at the moment if you only want to click the Knit button in RStudio---you have to call rmarkdown::render() and specify the output filename in the call, e.g.,
rmarkdown::render('file.Rmd', 'bookdown::pdf_book', output_file = 'book.pdf')
rmarkdown::render('file.Rmd', 'bookdown::beamer_presentation2', output_file = 'beamer.pdf')

Is there a way to override the content of notification email from a test case update in Kiwi TCMS?

Im trying to change the content of the notification email sent after a test case has been updated to better clarify what has been changed. As it is, the content is hard to read.
Went through the link below to configure the other notification content:
http://kiwitcms.org/blog/atodorov/2018/08/06/how-to-override-templates-for-kiwi-tcms/
The content of the notification email:
Updated on Tue Aug 20 15:47:18 2019
Updated by Admin
--- notes
+++ notes
## -1 +1 ##
-TestTest
+TestTest123123
--- text
+++ text
## -10,7 +10,7 ##
3. item
*Expected results*:
-
+Test
1. item
2. item
3. item
I managed to replicate the example (from the link) for post_case_delete, post_run_save, and user_registered but the dir(tcms/templates/email/) lacks one for test case updates.
EDIT: It seems that adding dir and txt files for the others will undo the changes made to confirm_registration.
Is there a way to amend how the content is shown in the notification email?
Im trying to change the content of the notification email sent after a test case has been updated to better clarify what has been changed.
The link you've posted shows how to override templates (HTML, email, any kind of templates). However what context (e.g. which variables) get passed down to the template is up to the backend functions rendering that particular template.
As it is, the content is hard to read.
We thought diff is a pretty universal format but if you have other suggestions the best way is to start with opening an issue with examples, maybe a POC pull request.
In this particular example change history is automatically generated so any change will likely affect everything which deals with history but we need to see examples to comment further.
EDIT: It seems that adding dir and txt files for the others will undo the changes made to confirm_registration.
This is unrelated to the original question. Again I will have to see what exactly you are doing to tell you if/where the mistake is. The template engine in Django is trying to use the first template with a given name it finds. The search directory path tells it where to look for these templates. If you are somehow obscuring the files from the blog post then the application will not be able to find them hence you are not seeing the overriden changes you expect to.
Also follow https://github.com/kiwitcms/Kiwi/issues/1076 (not directly related but in the same domain space).

PhpStorm: possible to update file template on each file edit?

My PhpStorm 2017.2 project requires that each new file be created from a specific. In "Settings >> Editor >> File and Code Templates >> PHP File", I have the following template:
<?php
/**
* #author John Doe
* #copyright ${YEAR} Acme
* #created ${DATE}
* #modified ${DATE}
*/
This works well. PhpStorm fills in the year and date dynamically. However, when I later come back and make changes to the file, I always need to remember to change the #modified line manually. Is there a way to automate this so that onSave or onCommit (for version controlled file), the line is updated with the current value of ${DATE}?
Not possible ATM.
https://youtrack.jetbrains.com/issue/IDEABKL-7178 -- watch this ticket (star/vote/comment) to get notified on any progress. Right now there are no plans to implement something like that in nearest future.
On another hand (as mentioned in the comment in aforementioned ticket) -- see if standard "Copyright" plugin will be of any help (never used it myself so no idea of what exactly it can do).
One possible solution involves writing your own script/program (PHP or whatever other language you can use) that will parse your file (regex matching should do fine here -- no real need into going and parsing file into tokens) and update such info:
look at each line until the matching line will be found (some guard logic can be added to limit the number of lines to be parsed: if no matching line is found in first xx (e.g. 20) lines then assume that this file has no such comment/line);
update date/time part based on file modification timestamp.
Once you have such script -- just use File Watcher functionality so it gets called on each file modification.
Possible downside: File Watcher gets triggered when file modification is detected ... which may include changes made outside (e.g. another editor/download from remote host/another VCS branch/etc)). This may lead to unnecessary/unwanted updates.
If File Watcher functionality is not suitable for whatever reason -- look into grunt -watch or alike where you may easily disable watching (so your script will only be called when your watcher (build runner) is watching).

C++ Windows API DlgDirList sometimes don't return the correct listing

I have 2 List Box, one always listing directories from a path and other listing the files from the selected directory.
The first time i select a directory, the files are shown properly, but if i select another directory, it lists nothing.
That's my current main.cpp, where all GUI stuff happens: http://pastebin.com/PjSb8aKy
List Box codes goes from lines 31 to 45 and 150 to 165.
Thanks in advance.
--------------------------------------------------EDIT---------------------------------------------------------------
I put a simple std::cout on the sel string, the result is that on the first directory i select, it's "", then it becomes "DirectoryName\", i tried changing the sel string to be "./DirectoryName", didn't managed to do it, the "\" still appears, but that isn't what bothers me, the real weird stuff is the first selection returning "" to the sel string...
I think the clue is in the docs for the DlgDirList function:
If lpPathSpec specifies a directory, DlgDirListComboBox changes the
current directory to the specified directory before filling the list
box.
I've never used these functions myself but I'd bet that your current directory is being modified and so subsequent calls to DlgDirList are looking in the wrong place.

Is there anyway to rename the "Source" button to something like "HTML"?

Is there anyway to rename the "Source" button to something like "HTML", I ask this as users are confused at how to add html code using the editor?
Yes, inside of the "lang" folder you will see all of the various language files.
For my case, and probably yours, You will want to edit the file "en.js". The file is "compressed" to some degree so it may be difficult to read, but it's still not too difficult to change one string. If you do plan on changing multiple strings you will most likely want to use a service to format Javascript.
Search for the following segment of code. It was one of the very last lines in the file.
"sourcearea":{"toolbar":"Source"}
change it to
"sourcearea":{"toolbar":"HTML"}
Avoid This Method Unless Required
And as for a very unsuggested method, since you can't modify the language files for some reason, you can modify the ckeditor.js file and force a specific label.
Inside of "ckeditor.js" change the line below
a.ui.addButton("Source",{label:a.lang.sourcearea.toolbar,command:"source",toolbar:"mode,10"});
to the follow code
a.ui.addButton("Source",{label:"HTML",command:"source",toolbar:"mode,10"});
The only thing modified is the "label" value in the above line. We remove the reference to the a.language.sourcearea.toolbar and insert a string in it's place instead.