Code search in Gforge AS 5.7

One of the new features of Gforge AS 5.7 is the support for source code indexing/search using doxygen and tsearch2 in both Subversion and CVS repositories. In this article, we’ll go trough a complete example to show the highlights of this feature.


In order to use this feature, you’ll need doxygen. You can get it from your distribution repositories or compile it from source.

After installing doxygen, you may need to edit your /etc/gforge/gforge.conf file. Look for the $config['doxygenPath'] configuration variable, and change it as need.ed Then, recreate the configuration cache.

#cd /opt/gforge5 && php bin/create_config_cache.php

Setting the path for code indexing

If you want to enable the code indexing in a given project, you’ll need to set one or more source code paths. In this example we will use subversion, but you can accomplish the same with CVS.

Navigate to SVN->Admin->Code search paths, you will see a screen like this

Browse search paths

In this example we will use the source code from pgadmin, a graphical client for PostgreSql.
We are interested in the code under /trunk/pgadmin path, so let’s proceed to add the path.

Index path added

In this case we are using C++, but doxygen can handle several  other languages (C, Java, Objective-C, Python,PHP, etc), check the doxygen documentation for a complete list of supported languages.

Now that we have configured the path a cronjob executed on a daily basis will index all the code found under the specified path. However, you can run the indexing script manually:

#cd /opt/gforge5
#php bin/gforge cronjobs scm_index

Some searching examples

Now that we have all the source code indexed, we can search for classes, methods and properties in the last revision.

Let’s search for the class PgsRecord

First search

The search will return a long list of methods and properties for this class and the class itself, this is just a small sample

Search results

The fields returned are self-explanatory. Comments will be shown for a given item if there is any.

You can search for a specific method or property inside a given class by using :: or . operators (ie: PgsRecordset::insert and PgsRecordset.index are equivalents)

Second search example

In our final example, we will use the tsearch2 operators. Suppose you want to look for setters in PgsRecord or PgsParser classes, we can use the tsearch2 OR operator (|)

Third search example

git support in GForge

Note: If you’re looking for git support in GForge AS, up to and including 6.4.5, please contact GForge Support for assistance.  Documentation for GForge AS is being retired in favor of the current product.

GForge Next provides full support for the git SCM (Source Code Management) tool, in addition to SVN and CVS.

Unlike SVN and CVS, git is a distributed tool where each user has a copy of the full repository in his or her machine. The basic workflow of git involves committing changes against the local repository and sharing the changes via pull and push operations.

Since commits in the local repositories cannot be “seen” by the GForge server, GForge sets up a global, centralized (“bare”) repository where the changes can be pushed to.

Setting up your project for git

To enable git support for your project, you need to be a project administrator. In the Project Admin tabs, select “Modules”, make sure that “Code Repository” is turned on, then select “git” as the SCM tool.  Click the “Save Changes” button at the bottom of the modules list to update the project.

Screenshot from 2022-10-24 19-28-23


Note: Changing the “Code Repository” setting does not delete any existing repository.  The GForge Next UI shows only the active SCM type.  Also, switching from git to svn and back to git only re-connects the existing git repository.  Nothing is deleted!

Once the repository is created, you will see the empty repository in the Git section:

Screenshot from 2022-10-24 19-34-26

If you repository is brand new (empty), you’ll see the friendly prompt above, with no data.  Let’s change that by adding data to your git repository.

git Basics

First, let’s take a small detour to talk about git as a tool.  There are lots (and lots and lots) of git commands, and you should be familiar with the basics before tackling the rest of this walk-through – or have a GUI tool that handles the nuts and bolts for you.

GForge Next includes some links to helpful information about git.  You’ll also notice the “Get Support” button in the screen shot – don’t hesitate to get in touch with any git-related question, whether it’s specific to GForge Next or not.

Screenshot from 2022-10-24 19-54-15

Cloning git Repositories

The first step in using your project’s git repository is to clone the repository.  Every team member who wants to contribute to the repo will do this as well.  The information you need is located on the Information tab, in the “Access Your Repository” section:

Screenshot from 2022-10-24 19-41-13

Depending on the site and project settings, your repository might be available via HTTPS (by default) or SSH. 

Note: If you have an existing repository, it’s actually even easier to get started.  Go into the directory for the existing repo, change the “origin” remote to the URL in GForge Next (with git remote set-url origin <newURL>), and do a “git push” to get everything moved in.

Copy the command from the text box and run it on your own computer (from a terminal, Command Prompt window or add the URL to your favorite git GUI tool).  After this, you’ll have a new directory to work in, containing, well, nothing – yet.

Adding the initial data

At this point, the git repository is empty and is not very useful, so let’s add files, create a commit, and push that commit to your GForge Next project repository.

First, you’ll need to checkout a branch, or in this case, create one.  Do git checkout -b main to create the default branch that git expects for new repositories.  You can use any name you want, but almost all git repositories have a main branch, so it’s useful to observe this convention for others coming to the project.

Create or copy any file you need (e.g., README) into your local copy of the repository (the directory created by the git clone command, earlier), then use git commit -a -m 'First commit!' to create the commit.

Note: The words ‘First commit!’ are completely up to you.  There’s no conventional first message for git.

When you’ve built up one or more commits like this, you can push them to the repository, using git push origin main.  After a successful push, you’ll see data in the Information tab Activity chart,

Screenshot from 2022-10-24 20-11-02

the new commit(s) will be listed in the Commits tab next to Information,

Screenshot from 2022-10-24 20-11-19

and the changes you’ve pushed will now be visible when you browse the repository.

Screenshot from 2022-10-24 20-11-57

Integration with GForge trackers

You may have noticed this section in the Information page:

Screenshot from 2022-10-24 20-14-24

Using the square-bracket notation in your commit messages (or in your branch name!) allows GForge Next to connect the code changes in your repository to the tasks that caused them.  This integration goes both ways – you’ll see links to Tracker Items in the SCM Commits list, and you’ll see the list of related commits in the details for each Tracker Item.

In the Project Admin SCM tab, you’ll also find settings to ignore, allow, or require references to Tracker Items, as well as some similar settings that can be helpful in managing developer workflow, security, and audit.

Setting up Access Control Lists

The Access Control Lists (ACLs) provide fine-grained permissions control in the source code repository, allowing you to specify read and write access for the different users in your project to different branches in the repository.

Note: This works differently in git than for Subversion, because git branches are physically separate from paths, whereas Subversion branches are paths in the repository.  Subversion ACLs are path-based because all repository users will share the same directory structure.

To view or edit the ACLs for your project’s git repository, go to Project Admin, and click the “SCM” tab.  You’ll see two more tabs open under it: “Settings” and “Access Control List”.  You can add or remove branch names from the list, and change the access level for each role in your project.  Users will get the highest access level across any roles they might have.

Screenshot from 2022-10-24 20-19-39


That’s enough to get you started using git in GForge Next.  Of course, there are many more features, settings, and workflow options available to suit your process and team’s needs.  Don’t hesitate to submit a ticket using the “Get Support” button with any git or GForge Next-related questions.

Happy git-ing!