Added function to get git config
Added checking of user.email and user.name when committing
Added possibility to configure global git parameters
Added QDialog extension to choose the name and email, with possibility to save the settings as global and validation.
Used the extension to handle the lack of user.name or user.email configured when committing.
Added unit tests for readConfigOption and setConfigOption.
This fixes the Bug 347351
Details
The new dialog works fine.
Tests pass.
Diff Detail
- Repository
- R33 KDevPlatform
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
can you create a test for that please?
plugins/git/gitnameemaildialog.cpp | ||
---|---|---|
33 | could you use a .ui file created in designer please? that makes it simpler to maintain UI and change it in the future |
@mwolff What do you want my to tests using unit test?
The dialog source (especially after using .ui from Designer) will be very simple. I will only use some abstract functions from other classes. So the potential unit test will in fact be testing the functionality of QRegExpValidator and I don't actually know what else there is to test.
The changes to commit function could be tested (I actually don't know how to test UI interactions, if I don't have the pointer to the QDialog), but again what is there to test? I'm just invoking a getConfigOption, setConfigOption and the QDialog.
What could be tested is the getConfigOption and changes to setConfigOption, but this are also very very simple functions and there isn't any test for the old setConfigOption.
Changed to .ui file from Designer instead of deffineing the ui in c++ source
Style fixed in gitplugin.cpp
- Fixed isssues and moved value.chop() to readConfigOption funtion
- Added unit tests for readConfigOption and setConfigOption
plugins/git/gitnameemaildialog.cpp | ||
---|---|---|
41 | use QRegularExpressionValidator | |
58 | remove extra spaces | |
66 | add newlines between functions | |
plugins/git/gitnameemaildialog.h | ||
45 | remove get prefix, i.e. follow the Qt style. Also remove the Field everywhere. void setName(const QString& name); // also note the const! void setEmail(const QString& email); // also note the const! QString nameField() const; QString emailField() const; bool isGlobal() const; | |
52 | both of these could be put into QScopedPointer or std::unique_ptr. Then remove the delete ... lines from the destructor. I.e. in the .cpp file then write: GitNameEmailDialog::~GitNameEmailDialog() = default; | |
plugins/git/gitnameemaildialog.ui | ||
54 | rephrase slightly: You have not yet configured the name and email to be associated with your Git commits. | |
114 | no buttonbox? | |
plugins/git/gitplugin.cpp | ||
429 | if (email.isEmpty() || name.isEmpty()) | |
1485 | please share code, make the QStringList accessible and append --global optionally. No need to copy'n'paste 99% of the code for just that purpose | |
1504 | this may still break on windows, so either use QTextStream and it's readLine, or return a trimmed value. I can't think of a situation where that could break. Whitespaces in config values should not matter afaik. | |
plugins/git/tests/test_git.cpp | ||
271 | remove the QDebug, and rewrite this test to make it data-driven, (i.e. use QTest::newColumn, QTest::addRow, QFETCH and a testLocalConfig_data()). | |
plugins/git/tests/test_git.h | ||
46 | const& the QString args |
plugins/git/gitnameemaildialog.ui | ||
---|---|---|
114 | In Qt-designer it's not possible to add custom name to a button in button box. (or I wasn't able to find a way) | |
plugins/git/tests/test_git.cpp | ||
271 | At first I tried to make it data driven, but the initTestCase() and cleanupTestCase() seamed to be interfering with this test. As I don't understand how they are working, I haven't touched them. What I found out is, that repoInit() has to be called at the beginning of the test, because the repo seams to be deleted between tests. If I used data-driven tests the repo would be reinitialized between each test case and that would break my tests. |
- Fixed style
- Changed description in dialog
- QRegExp -> QRegularExpression
- \* -> QScopedPointer
plugins/git/gitnameemaildialog.cpp | ||
---|---|---|
24 | No global module includes please. Use QDialog and friends | |
41 | I don't get that regexp. This is accepting everything, right...? Which makes it useless as a validator regex. | |
plugins/git/gitnameemaildialog.h | ||
43 | Style: Use const QString& name, same below and in other places | |
50 | Typo: refresh. Better just call that function updateUi | |
plugins/git/gitplugin.cpp | ||
434 | Style: { on same line, same below |
plugins/git/gitnameemaildialog.cpp | ||
---|---|---|
41 | It's everything *except* nothing :) So this is an easy validator to ensure the field is not empty. |
plugins/git/gitnameemaildialog.cpp | ||
---|---|---|
41 | Oh, indeed. Not an issue then. Thanks. |
plugins/git/tests/test_git.cpp | ||
---|---|---|
268 | This test is too complicated for the test coverage it achieves. This would basically reach the same coverage:
Kill GitInitTest::runTestLocalConfig, call {set,read}ConfigOption directly in here. |