Skip to content

Repository for Crew C - Differential Evolution

Notifications You must be signed in to change notification settings

pippowell/DiffEv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiffEv

Repository for Crew C - Differential Evolution

Git branch handling

Please always create sub-branches of your corresponding group branch for every new feature/function/bugfix you make: prog2/feature/nameOfFeature

To do so, click on "create a new branch" in the corresponding task you're going to work on. That way, the branch is automatically linked to that task.

1. Project organization

To get a better sense of how your files should be organized, here's a simplified structure of our Python project:

DiffEv
├── docs
│   └── doc.md
├── task_name
│   ├── ...
├── tests
│   └── test_code.py
├── .gitignore
├── README.md
├── requirements.txt
├── pylintrc
├── .style.yapf

2. Developing

2.1 Prerequisites

TBD

2.2 Setting up Dev

git clone https://github.com/pippowell/DiffEv.git
cd DiffEv/
python install -r requirements.txt

2.3 Python Style Guide

We'll use the Python Style Guide provided by Google. Code style will be checked using pylint and yapf via either pre-commit hooks or GitHub Actions after your commit.

While Python does encourage duck typing, please use types as much as possible, especially on function parameters, class constructors and so on. This will enable a more efficient teamwork and leads to less bugs due to TypeErrors.

2.4 Some Git rules

There are a set of rules to keep in mind:

  • Perform work in a feature branch.

    Why:

    Because this way all work is done in isolation on a dedicated branch rather than the main branch. It allows you to submit multiple pull requests without confusion. You can iterate without polluting the master branch with potentially unstable, unfinished code. read more...

  • Never push into main branch. Make a Pull Request.

    Why:

    It notifies team members that they have completed a feature. It also enables easy peer-review of the code and dedicates forum for discussing the proposed feature.

  • Update your local development branch and do an interactive rebase before pushing your feature and making a Pull Request.

    Why:

    Rebasing will merge in the requested branch (main) and apply the commits that you have made locally to the top of the history without creating a merge commit (assuming there were no conflicts). Resulting in a nice and clean history. read more ...

  • Resolve potential conflicts while rebasing and before making a Pull Request.

  • Delete local and remote feature branches after merging.

    Why:

    It will clutter up your list of branches with dead branches. It ensures you only ever merge the branch back into (main) once. Feature branches should only exist while the work is still in progress.

  • Before making a Pull Request, make sure your feature branch builds successfully and passes all tests (including code style checks).

    Why:

    You are about to add your code to a stable branch. If your feature-branch tests fail, there is a high chance that your destination branch build will fail too. Additionally, you need to apply code style check before making a Pull Request. It aids readability and reduces the chance of formatting fixes being mingled in with actual changes.

2.5 Git workflow

Because of most of the reasons above, we use Feature-branch-workflow with Interactive Rebasing and some elements of Gitflow (naming and having a develop branch). The main steps are as follows:

  • For a new project, initialize a git repository in the project directory. For subsequent features/changes this step should be ignored.

    cd <project directory>
    git init
  • Checkout a new feature/bug-fix branch.

    git checkout -b <branchname>
  • Make Changes.

    git add <file1> <file2> ...
    git commit

    Why:

    git add <file1> <file2> ... - you should add only files that make up a small and coherent change.

    git commit will start an editor which lets you separate the subject from the body.

    Read more about it in section 1.3.

    Tip:

    You could use git add -p instead, which will give you chance to review all of the introduced changes one by one, and decide whether to include them in the commit or not.

  • Sync with remote to get changes you’ve missed.

    git checkout develop
    git pull

    Why:

    This will give you a chance to deal with conflicts on your machine while rebasing (later) rather than creating a Pull Request that contains conflicts.

  • Update your feature branch with latest changes from develop by interactive rebase.

    git checkout <branchname>
    git rebase -i --autosquash develop

    Why:

    You can use --autosquash to squash all your commits to a single commit. Nobody wants many commits for a single feature in develop branch. read more...

  • If you don’t have conflicts, skip this step. If you have conflicts, resolve them and continue rebase.

    git add <file1> <file2> ...
    git rebase --continue
  • Push your branch. Rebase will change history, so you'll have to use -f to force changes into the remote branch. If someone else is working on your branch, use the less destructive --force-with-lease.

    git push -f(orce-with-lease)

    Why:

    When you do a rebase, you are changing the history on your feature branch. As a result, Git will reject normal git push. Instead, you'll need to use the -f or --force flag. read more...

  • Make a Pull Request.

  • Pull request will be accepted, merged and closed by a reviewer.

2.6 Writing good commit messages

Having a good guideline for creating commits and sticking to it makes working with Git and collaborating with others a lot easier. Here are some rules of thumb (source):

  • Limit the subject line to 50 characters.

  • Use imperative mood in the subject line.

    Why:

    Rather than writing messages that say what a committer has done. It's better to consider these messages as the instructions for what is going to be done after the commit is applied on the repository. read more...

  • Use the body to explain what and why as opposed to how.

3. Tests

TBD

Describe and show how to run the tests with code examples. Explain what these tests test and why.

Give an example

About

Repository for Crew C - Differential Evolution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published