#4 add `cranc pr list`
Merged 5 years ago by lenkaseg. Opened 5 years ago by lenkaseg.
lenkaseg/cranc add_pr_list  into  master

file modified
+19 -4
@@ -6,8 +6,10 @@ 

  

  ### What Cranc does

  

- Nothing.

- But soon it should be able to list pull requests.

+ At the moment cranc lists pull requests.

+ With this command:

+ 

+ `cranc pr list`

  

  ### About its name

  
@@ -18,13 +20,26 @@ 

  

  Create the virtual environment:

  

- `python3 -m virtualenv env`

- `source env/bin/activate`

+ `virtualenv3 ~/venvs/cranc-env`

+ `source ~/venvs/cranc-env/bin/activate`

+ 

+ Retrieve the sources:

+ 

+ `git clone https://pagure.io.cranc.git`

+ `cd cranc`

  

  Install dependencies:

  

  `pip install -t requirements.txt`

  

+ Run the setup file. This creates a link in the venv directory pointing to the cranc directory:

+ 

+ `python setup.py develop`

+ 

  Run the app:

  

  `cranc`

+ 

+ Or run the command:

+ 

+ `cranc pr list`

file modified
+38 -5
@@ -1,12 +1,45 @@ 

  import click

- import requests

+ import pprint

+ 

+ from libpagure import libpagure

  

  @click.group()

- def lists():

+ def cranc():

      pass

  

- @click.command()

- def list_pull_requests():

+ api_token = os.getenv('CRANC_TOKEN')

+ 

+ 

+ ################################################################################

+ # PR section

+ ################################################################################

+ 

+ @click.group()

+ def pr():

      pass

  

- lists.add_command(list_pull_requests)

+ @click.command()

+ #@click.option('--author', default='all')

+ 

+ def list():

+     """ 

+     Get all pull requests of a project.

+     :param status: filters the status of the requests

+     :param assignee: filters the assignee of the requests

+     :param author: filters the author of the requests

+     :return:

+     """ 

+     pagure = libpagure.Pagure(pagure_token=api_token, pagure_repository='pagure')

+     prs = pagure.list_requests()

+     

+     pprint.pprint(prs)

+ 

+ pr.add_command(list)

+ 

+ 

+ 

+ ################################################################################

+ # General section

+ ################################################################################

+ 

+ cranc.add_command(pr)

file modified
+1
@@ -2,4 +2,5 @@ 

  # Use this file by running "$ pip install -r requirements.txt"

  

  click

+ libpagure

  requests

file modified
+1 -1
@@ -16,6 +16,6 @@ 

      author_email='lenka@sepu.cz',

      entry_points="""

      [console_scripts]

-     cranc=cranc.cranc:lists

+     cranc=cranc.cranc:cranc

      """

  )

cranc pr list fetches all the pull requests from pagure project
README.md also updated

Fixes #1

rebased onto 793c08b

5 years ago

Looks good for me, let's merge and continue on top

Pull-Request has been merged by lenkaseg

5 years ago