Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tcd1558/e8491655c039330f9ac1570be5695b63 to your computer and use it in GitHub Desktop.
Save tcd1558/e8491655c039330f9ac1570be5695b63 to your computer and use it in GitHub Desktop.
Project management using a PyCharm Python project with a GitHub repository.

Project Management using a PyCharm Python project with a GitHub repository.

0. Overview

This document describes the flow of actions needed from a repository administrator(RA) and the team members(TM) to collaborate on a project. As a first step, the PyCharm Python project has to be added into a github repository as described in the gist:
https://gist.github.com/tcd1558/a838deda7dd5968bab6c3d88b9aa466d

Once the project is available in GitHub, the RA announces the availability of the repository: https://github.com/<RA_user>/<MyProject>

Modifications to the repository are driven through issues filed against a repository.

1. Index

  1. Overview
  2. Index
  3. Syntax
  4. Add collaborators to the project
  5. Accepting an invitation to collaborate
  6. How to file an issue.
    5.1 Assign somebody to an issue
  7. How do I work with a specific version
    7 Make changes
    7.1 Update your work branch.
  8. Submit solution to issue as a <TM_user>
  9. Report back, that the issue has been addressed and is ready for review
  10. Open a Pull Request(PR) to review code and merge with main branch/tree
  11. Code Review.
    11.1 Change required.
    11.2 Provide Approval to merge code in to main branch in GitHub.
  12. Tag a revision for release

2. Syntax

[button] - is a button on the screen with the text 'button' on it.   
InputField: - is a field labeled 'InputField:', where you can enter text.   
<PlaceHolder> - a placeholder to be replaced with your own text (without the '<' and '>').  
[v] Label1 - ensure there is a check mark in front of the label 'Label1'
[x] Label2 - ensure there is an 'x' in the check box in front of the label 'Label2'
1/3 - step 1 of in total 3 steps
$ - prompt for a regular user
# - prompt for the root user (system administrator)

RA_user - Repository Administrator account
TM_user - Team Member account/collaborator

3. Add collaborators to the project

As <RA_user/>:
GitHub Repositories Select <MyProject> (Cog Wheel) Settings
Manage Access (in the left menu)
[Invite a collaborator] (green button, center panel)
[Add <user> to this repository]
Add other GitHub Team Member (TM) users
Copy invite link by using the clipboard icon
https://github.com/<RA-user>/<MyProject>/invitations

4. Accepting an invitation to collaborate

As <TM_user>:
Verify, that you are signed in as <TM_user>
Open your email reader
Find an email with the subject '<RA_user> invited you to <RA_user>/<MyProject>
Check that the email was sent by noreply@github.com (Phishing)
Check that the green button [View Invitation] links to https://github.com/<RA_user>/<MyProject>/invitations (Phishing)
If everything looks right, view the invitation.
Your browser should now display the github page and a green button [Accept Invitation]. Click this button.

5. How to file an issue

Assumption: everybody can file an issue
Go to the projects main repository page:
https://github.com/<RA_user>/<MyProject>
Underneath the project title <RA_user>/MyProject click on the [issues]
Then click on the green button [Create issue] or [New issue] to the top right.
Give the issue a Title and describe the issue in more detailed in the 'Leave a comment'-box.
Note: Do not forget to mention which branch, tag, commit you are filing the issue against.
Click on the green [Submit new issue].

5.1 Assign somebody to an issue

On the project page https://github.com/<RA_user>/<MyProject> click on the tab [Issues].
If there is more than 1 open issue, double click the issue, you want to assign.
On the right hand side, there is a sections labeled 'Assignees'.
Click on 'Assignees' or the Cog Wheel (Settings) next to it.
Select the 'collaborators' you want to assign this issue to.

Click somewhere outside the 'Assignees' section to activate your selection.

6. How do I work with a specific version

As assignee you open Pycharm and in the Welcome to Pycharm screen you select you select:
[Get from VCS]
Select the <TM_user>

If the <TM_user> does not show up, close 'Get from VCS' window.
Then press CMD+, or from the top bar select PyCharm, Preferences
- Version Control
- GitHub
- Make sure you are not logged in GitHub with the <RA_user>
- Click on the [+] at the bottom of the right side window
- Follow the instructions to login to GitHub with the <TM_user>
- Close the PyCharm Preferences window by clicking on [OK]
- Click on 'Get from VCS'

On the left panel under GitHub, select the <TM_user>
Select <RA_user>/<MyProject>
If you already have this project on your local system from the <RA_user>, rename the field 'Directory:' with e.g. _TM or _<TM_user>
[Clone]

At the bottom right in the margin, change the active branch/tag to the version for which the issue was reported. Once you have selected the branch/tag for which the problem was reported, it is strongly advised to create a new branch to fix the problem. If you use your own branch, the reviewer can clone your branch for verification, before the changes go into the main tree/branch. The name of branch could be <branch>_<issue#>.
Creating a new branch everytime you address an issue ensures that you are working on an updated tree.

Right Click, Git,
New Branch... <branch>_<issue#>

7. Make changes

Address the reported issue.

7.1 Update your work branch

To make your submission as close as possible as the main tree/branch, perform a pull before pushing the changes to GitHub and requesting a review.

git pull --rebase origin main

Right Click, Git, Pull,
Specify branch: main.
Modify option v - use pulldown and select --rebase.
[Pull]

8. Submit solution to issue as a <TM_user>

Make sure you are not logged into GitHub, except for the <TM_user>.

git add

git commit

It is good practice to mention the issue your are responding to in the commit message <issue#> - <text>

git push

<branch><issue#> -> origin:<branch><isue#>
Notice: GitHub is now reporting the new tree, when clicking on the branch botton on the <>Code page.

9. Report back, that the issue has been addressed and is ready for review

Under <TM_user>@GitHub open the issues tab.

Click on the [(!) Issues] tab Click on the issue you just fixed Write a message to the <RA_user> that the issue has been addressed in your tree <branch>_<issue#> Assign the issue back to the <RA_user> [Comment]

10. Open a Pull Request(PR) to review code and merge with main branch/tree

Log in to GitHub as <TM_user>
Select <RA_user>/ThisProject
Click on the [Pull requests] tab. Not the Pull requests in the top, black bar.
[New pull request]
base: <branch>, <- compare: <branch><issue#>
[Create pull request]
Add Comment for <RA_user>
"I have added the solution for issue# into tree.
<branch>
<issue#>. Please have the code reviewed"
Add assignees (reviewers) - can also be done by the <RA_user>
If it is just the RA and the TM, assign the RA.
[Create pull request] - no need for the pull down menu

11. Code Review

11.1. Change required

            Login as <RA_user\>
            select <ThisProject\> - or select the pull request from Recent activity
            switch branch to <branch\>_<issue#\>
            click on tab [Pull requests]
            Read message
            with a single file:
                    Tab [Commits]
                    Click on the respective commits

                    If a change is necessary
                            Click Pull requests
                            Click Issue
                            Write
                            Leave a comment
                                    <my test>
                            Comment
                    If no change is necessary
                            <RA_user\> writes a comment to request the
                                    merge or does it by him-/herself
                            merge with main by engineer <TM_user\>
                            [Merge pull request v]
                            [Confirm merge]
                            Under 'Issue #', you should now see a purple
                                    [Merged] icon.

            Check main branch includes all changes
                    <\>Code
            Close Issue #
                    Issues
                    Select Issue
                    Write a comment
                    [Close with comment]
            If the tree <branch\>_<issue!\> is no longer necessary, you can remove the repository from your local disk.
            From the CLI you can check that all modifications are committed with:
            > $ git status

            with multiple files:
            clone, review

11.2. Provide Approval to merge code in to main branch in GitHub

12 Tag a revision for release.

See also A PyCharm Python project with a GitHub repository

Use

$ git tag
to see the current tag (if available)

At the remote GitHub repository gp to [main ] In the third row, select the tab [Tabs]

Tag your branch, so you can always get back to this point of the repository.

$ git tag v1.0
$ git push origin v1.0

or

Right Click on the project <MyProject>
Git
New Tag...
Tag Name: -- here the letter v is allowed as first character. After that, you should have a sequence of numbers and the period. For example: 'v1.0'. A Tag can not have words like e.g. 'Winter2020/2021'.

Restrictions unclear: 'Commit:' is a reference for a commit
Message can be verbous

Git, Push...
[v] Push Tags
[All v]
Push

By default, the git push command doesn’t transfer tags to remote servers. git push origin https://git-scm.com/book/en/v2/Git-Basics-Tagging

PyCharm does always create a complete clone with all of its branches. Therefore when starting from the welcome screen with 'Get from Version Control' you will always get all branches, tags, ..
If you have to work on a specific branch/tag, you need to changes branch/tag on the bottom right of the screen.

I have not found a way to compare a file against a tagged version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment