Imprudence:Contributing Code

From Kokua Wiki

(Redirected from Contributing Code)
Jump to: navigation, search

Contents

How to Contribute Code

The best way to submit any code contribution (bug fix, new feature, etc.) is with this process:

  1. Clone the Imprudence Git Repository and push a new Git branch containing your changes. Or, to create a patch file with your changes (but, we prefer a Git branch). If you need help with Git, please see our Git Primer or the documentation on the Git website, or contact us.
  2. Create a new issue on our issue tracker, if there isn't an issue related to your feature or bug fix already.
  3. In the issue description or comment, please summarize the changes you made, in plain English. Also, be sure to tell us the names of everyone who worked on it, so that we can give due credit for the contribution.
  4. Set the issue status to "Ready to Merge", and tell us where to find your contribution (i.e. your Git repository location and branch name). Or, if you created a patch, attach it to the issue.
  5. The Imprudence developers will take a look at your change, and we will probably discuss it (unless it's very simple and obvious). If it looks good, a developer will merge it into their repository. From there it will make its way into the final code!
  6. Remember when using git:
Imprudence uses LF (Unix) line endings
Make sure that's what you're using when you
clone/push or you'll cause merge conflicts

If you want to get feedback from the developers and other people before submitting your contribution, please send a message to the mailing list.

It is recommend to make changes by branching from the "exp" branch. Any patches you make and contribute would be merged with the "next" branch for testing before being merged with "exp". When an Experimental is feature frozen for bug fixing and its stable enough for a stable release it will be pushed to the "master" branch.

Code Contribution Guidelines

Contributions from the community are much appreciated — they are what make Imprudence great! Follow these guidelines to make sure your contribution can be incorporated quickly and easily:

An example from llpanelavatar.cpp and panel_avatar.xml:

childSetText("notes edit", getString("Loading"));

<string name="Loading">
        Loading...
</string>
/**
 * @file {FILENAME}
 * @brief {BRIEF DESCRIPTION OF FILE CONTENTS / PURPOSE}
 *
 * Copyright (c) {YEAR}, {YOUR NAME}
 *
 * The source code in this file ("Source Code") is provided to you
 * under the terms of the GNU General Public License, version 2.0
 * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
 * this distribution, or online at
 * http://secondlifegrid.net/programs/open_source/licensing/gplv2
 *
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at
 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
 *
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 *
 * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 */

And finally:

Patch Formatting

If you submit a patch (rather than creating a Git branch), it should be in the unified diff format.

Git

The easiest way to generate a unified diff patch is to use git, e.g.:

$ git diff -u HEAD~1 > C:\your_change.patch

See git-diff for more information.

Diff

You can also use diff to generate patches.

Create two copies of your source tree. Leave one unmodified, include your changes in the other. You can use diff -u to compare the two and generate patches.

For single files:

diff -u original_source\linden\indra\newview\llfile.cpp modified_source\linden\indra\newview\llfile.cpp > C:\your_change.patch

For multiple files, you need to compare directory trees. Files can be excluded by using the --exclude flag (see the manual):

diff -u --exclude="pattern" original_source modified_source

Multiple files can also be added to the patch manually by using the >> operator:

diff -u original_source\linden\indra\newview\llfile.cpp modified_source\linden\indra\newview\llfile.cpp > C:\your_change.patch
diff -u original_source\linden\indra\newview\llfile.h modified_source\linden\indra\newview\llfile.h >> C:\your_change.patch

Sample Output

Here's what a typical patch looks like:

diff --git a/linden/indra/newview/llselectmgr.cpp b/linden/indra/newview/llselectmgr.cpp
index 998cc50..f46f104 100644
--- a/linden/indra/newview/llselectmgr.cpp
+++ b/linden/indra/newview/llselectmgr.cpp
@@ -4552,6 +4552,11 @@ extern LLGLdouble	gGLModelView[16];
 
 void LLSelectMgr::updateSilhouettes()
 {
+	if (!mRenderSilhouettes || !LLSelectMgr::sRenderSelectionHighlights)
+	{
+		return;
+	}
+
 	S32 num_sils_genned = 0;
 
 	LLVector3d	cameraPos = gAgent.getCameraPositionGlobal();

Coding Standards

if (option)
{
      doThis();
}

as opposed to:

if (option)
      doThis();
#ifndef LL_LLFOO_H
#define LL_LLFOO_H

#include "llbar.h"

class LLReferencedData; // forward declaration (no need to include "llrefrenceddata.h")

class LLFoo : public LLBar
{
public:
    LLFoo();
    void setData(LLReferencedData& refdata);
private:
    LLReferencedData* mRefData;
};

#endif //LL_LLFOO_H
Personal tools
Namespaces
Variants
Actions
Navigation
Wiki
Toolbox