Skip to content

Commit

Permalink
added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
IamShobe committed Nov 19, 2018
1 parent af1641c commit 39c0288
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 3 deletions.
94 changes: 93 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,96 @@
[![Build Status](https://travis-ci.org/yakobu/patch-issue.svg?branch=master)](https://travis-ci.org/yakobu/patch-issue)
[![Coverage Status](https://coveralls.io/repos/github/yakobu/patch-issue/badge.svg?branch=master)](https://coveralls.io/github/yakobu/patch-issue?branch=master)

Patch manager for easy tracking with integration in jira
Patch manager for easy tracking with integration in jira.

## Concept
We've all put patches over patches in our code, for various reasons:
* Hot fixing a currently released version
* Temporary place-holder
* Or just because we felt like it -
so we wouldn't have to design some complex structure.

This is where `patch-issue` comes into play.
We wanted to have a way of notifying the programmer
that the current code segment is a part of a patch -
using Jira issue tracking system and some kind of a logger.
Then, later on, `patch-issue` will notify the programmer (in runtime)
that the issue is closed and the programmer can remove the patch easily.

### Important Note
We do not encourge the usage of patches in a code segment.
This tool main purpose is to help programmers track their patches,
so they won't forget the patch in their code (long term wise).

## How to install?
Simply run:
```bash
$ pip install patch-issue
```
And try to import:
```python
import patch_issue
```

## Ok, So how to I start?
First, you need to make a connection to Jira in your code,
and just for that there is an awesome library called -
yeah you guessed right - `jira` - [jira pypi link](https://pypi.org/project/jira/).

Here is how to make a simple connection:
`connection.py`
```python
from jira import JIRA

jira_connection = JIRA(server="http://jira/", basic_auth=("username", "password"))
```

Now you can make a new patch class:
`patches.py`
```python
import logging

from patch_issue import JiraPatchIssue

from connection import jira_connection # from previously made connection


class FixDBConnection(JiraPatchIssue):
ISSUE_KEY = "APP-1" # a must have class attribute
DESCRIPTION = "Fixes db connection using a mocked password."
WAY_TO_SOLVE = "Configure the right password."

fix_connection = FixDBConnection(jira=jira_connection,
logger=logging) # there is also a default logger
```

Now you can use your patch freely in your code:
```python
import .config
from .db import DB

from patches import fix_connection # import your patch instance


##################################################################

@fix_connection.patch_function # use patch as a function decorator
def new_connection():
return DB.make_connection("user", "password")

new_connection()

##################################################################

usename = "someuser"
password = config.get_password()
with fix_connection.patch: # use patch as a context manager
password = "1234"

db = DB.make_connection(username, password)
```

Now, when your code reaches to the patches,
a message will be logged in your logger!
You will never miss your patches again!

9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from __future__ import absolute_import
from setuptools import setup, find_packages

__version__ = "0.7.3"
__version__ = "0.8.0"

with open("./README.md") as f:
long_description = f.read()

requirements = [
"colored",
Expand All @@ -11,7 +14,9 @@
setup(
name='patch_issue',
version=__version__,
description="",
description="Track your patches easily with Jira integration",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT",
author="yakobu & shefer",
author_email="ronenya4321@gmail.com",
Expand Down
1 change: 1 addition & 0 deletions src/patch_issue/mock_resources/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ def issue(self, issue_key):
issue_details = self.nown_issues.get(issue_key, self.DEFAULT_ISSUE)
return MockIssue(issue_key, issue_details.resolution,
issue_details.summary, issue_details.status)

0 comments on commit 39c0288

Please sign in to comment.