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:

Richard Stallman's political discourse on sex

Richard Stallman, the founder of the Free Software Foundation, has been subject to numerous allegations of misconduct. He stepped down in 2019, and following his re-instatement in 2021, a famous open letter was published in which numerous organizations and i…

via Drew DeVault's blog November 25, 2023

Upgrading to FreeBSD 14 - how to fix a broken BIOS bootcode

A lot of people running ZFS zroot have managed to break their FreeBSD systems upgrading from 13.2 to the new 14.0 release because of a broken BIOS bootcode. In this tutorial I'll show you how you can fix that without having to reinstall.

via unixsheikh.com November 22, 2023

C++ Guidelines

C++ is definitely a language that has Lots of Ways to do It – kind of like Perl’s TIMTOWTSAC. A consequence is that when writing code, you need to think about which way to do things. When context-switching between projects, employers, or what-have-you, yo…

via [bobulate] November 21, 2023

Generated by openring