r/learnprogramming • • Apr 28 '12

How to contribute to an opensource project.

I can code in C++ and Python to a reasonable level. I found something I'd like to change in an opensource program (amarok) and would like to implement and share if it's good enough. My question is this: whenever I have made my own applications or scripts in the past I have only used a single file which contains all the code. Large applications like this one seem to have many files and a git page I just want to know how I can, (I'm running ubuntu) change the source files and test them locally then perhaps share them. Thank you.

45 Upvotes

19 comments sorted by

21

u/[deleted] Apr 28 '12

To get the code:

git clone git://anongit.kde.org/amarok.git

Then read the INSTALL file to find out how to compile and, if needed, install the application. On Debian/Ubuntu you might want to run:

sudo apt-get build-dep amarok

To automatically get all the needed dependency, sometimes you will need to get never versions of the dependencies right from the source, but in most cases build-dep will give you what you need.

Once you figured out how to get the app running, just start hacking the source and compile it as before. Once done, read a Git tutorial. You will need to do two things, commit the source to your local git repository via:

git commit -m "description of things you changed" FILE1 FILE2

And then generate a patch via:

git format-patch origin/master

The generated files you can then email to the maintainer of the application. Oftentimes there are coding standards for the style used for descriptions and source code layout, so you might want to read and follow them to get your patch accepted.

1

u/SibyllineProvo Apr 28 '12

Thank you. This is just what I was after!

1

u/[deleted] Apr 28 '12

That just cleared up a lot for me, thanks.

39

u/[deleted] Apr 28 '12

Sorry, but these two statements:

I can code in C++ and Python to a reasonable level.

and:

whenever I have made my own applications or scripts in the past I have only used a single file which contains all the code.

are self-contradictory. Putting all your code in a single file is not viable for any reasonable sized C++ application, and hardly viable in Python. You are going to have to learn how to design, write and build multi-file applications before you think about contributing to a FOSS project. I have a series of blog articles about how to go about writing real C++ programs, including multi-file issues, starting here , which may (or may not) be helpful.

7

u/[deleted] Apr 28 '12 edited Apr 28 '12

That blog is awesome, it's exactly what I need.

You should post it as it's own post both here and the other subreddits like r/programming, r/coding etc. so more people can see it. :)

EDIT: Oh, the series is unfinished :( It's still really helpful though! It'd be a masterpiece if you could finish it though :P Although I gather it covers quite a lot. The Five Easy Pieces looks good too, I guess the title is a nod to Feynman?

→ More replies (2)

2

u/SibyllineProvo Apr 28 '12

Thanks for the link looks useful, but the statements are not self-contradictory unless you are defining reasonable level as experience building multi-file applications. Regardless, I didn't ask whether you thought I was capable of it yet (but thanks for the advice). I only wanted to get an idea of how a git works and how I can compile them locally. I don't see how being able to design and write a program on the scale of amarok is necessary for a little bit of tinkering, experimenting and learning.

Just out of interest, why is it necessary to have a separate file for anything? Why can't you just define new classes and/or functions?

→ More replies (8)

2

u/Suttonian Apr 28 '12

I can answer the first two questions, but I'm not sure how you would commit the changes. It looks like an e-mail address is given, and I'm not sure if simply pushing to this would work...Anyway.

To get the code you need to have git, open a console window and enter:

git clone git://anongit.kde.org/amarok.git somefolder

Which would copy all the code to somefolder. It's also going to retrieve the change history which you can browse locally with git. To test the changes there is usually a readme file which gives instructions for compilation.

2

u/CynicalPenguin Apr 28 '12

Talk to the developers and ask what they need done. (If somebody wanted to contribute to my projects, that's what I would want.)

1

u/[deleted] Apr 29 '12

I've found that the best bet is to identify a project you're interested in first, and go from there. Look up the project itself... the odds are that it's hosted on GitHub or SourceForge. The developers may also have a bug tracking system in place or even an IRC channel where you can contact someone and get involved.

The smaller the project the more you're likely able to contribute. If you want to start with something like VLC or Node.js then expect to be working on bug fixes for a while as you familiarize yourself with the software's design and code. If you work on something like PyTables you'll probably be able to build something substantial much faster.