KDevelop AppWizard - DVCS fix for empty project

Backstory

Few days ago I wanted to play with Falkon and create some basic Qml plugin. (What else to do to play, Python support is broken and C++ is for built-in plugins).

I started KDevelop (the big IDE I use) and went to create new Empty project because as I am not big Qml lover I did not create template for it yet. But I was met with errors which made me change my focus and fix the tool I use (KDevelop) before playing with Qml and Falkon.

Man must shape his tools lest they shape him. - Arthur Miller

Problem

During the project creation AppWizard is trying add files and than commit changes into new DVCS (Decentralized Version Control System) repository. When there are no files to add there will naturally be nothing to commit which results in error message from DVCS and the project creation is stopped and project removed.

Solution

Lets dive into KDevelop code and check what can be done about it. My humble solution relays on checking the state of the DVCS repository before commit. To achieve this I am trying to get actual status of the repository from VCS (Version Control System) and then checking if the result contains some items.

The KDevPlatform provides nice API to work with VCSs and thus I only need to call few method to get all the data.

Actual code is truly simple and works for me. (only my changes)

qCDebug(PLUGIN_APPWIZARD) << "Checking for valid files in the DVCS repository:" << dest;
job = dvcs->status({dest}, KDevelop::IBasicVersionControl::Recursive);
if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
{
    vcsError(i18n("Could not check status of the DVCS repository"), scratchArea, dest);
    return false;
}

if (job->fetchResults().toList().isEmpty())
{
    qCDebug(PLUGIN_APPWIZARD) << "No files to add, skipping commit in the DVCS repository:" << dest;
    return true;
}

Brief description

  • Print notice into debug output
  • Prepare job with status command to run
  • Execute the job and check for failure
    • If failed put notice in debug output
  • Check if the response contains some items
    • If not put notice in debug output
    • Skip add files & commit by returning true
  • Test many times and done.

Results

KDevelop is able to create Empty project from template with initialized DVCS repository which is really helpful when one wish to start a project from scratch.

Git

Works just fine.

Bazaar

The world is never perfect and there is always a room for improvements.

The merge request is waiting for review at invent.kde.org !73.

Articles from blogs I follow:

KDE Plasma Wayland keyboard layouts

Calamares is a Linux system installer used by dozens of distro’s to get the bits from an ISO image onto a target computer. Development is nowadays purely on a volunteer basis, which makes it hard to keep up with all the changes in the Linux world. But ste…

via [bobulate] September 14, 2024

There is only one reason why Microsoft Windows is the dominating operating system on the PC desktop

The Internet is filled with blog posts, articles on tech media, and videos on YouTube about why Linux is not the main operating system on the PC desktop. "5 reasons why", "10 reasons why", bla, bla, bla. But they are all wrong.

via unixdigest.com August 24, 2024

Signing Android Apps Using a YubiKey (on NixOS)

In my spare time, I currently develop two Android apps using Flutter: AniTrack, a simple anime and manga tracker based on my own needs, and Moxxy, a modern XMPP client. While I don't provide release builds for AniTrack, I do for Moxxy. Those are signed u…

via PapaTutuWawa's Blog July 24, 2023

Generated by openring