Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
assigned issue
Browse files Browse the repository at this point in the history
  • Loading branch information
myusuf3 committed May 25, 2012
1 parent dbe1d5e commit 3f41e1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
16 changes: 10 additions & 6 deletions octogit/cli.py
Expand Up @@ -30,7 +30,7 @@ def get_help():

puts('\n{0}:'.format(colored.cyan('tentacles')))
with indent(4):
puts(colored.green('octogit login'))
puts(colored.green('octogit login <username> <password>'))
puts(colored.green("octogit create <repo> 'description'"))
puts(colored.green("octogit create <repo> 'description' <organization>"))
puts(colored.green('octogit issues [--assigned]'))
Expand Down Expand Up @@ -85,13 +85,13 @@ def begin():
sys.exit(0)

elif args.get(0) == 'create':
if args.get(1) == None or args.get(2) == None:
if args.get(1) == None:
puts('{0}. {1}'.format(colored.blue('octogit'),
colored.red('You need to pass both a project name and description')))

else:
project_name = args.get(1)
description = args.get(2)
description = args.get(2) or ''
organization = args.get(3)
create_repository(project_name, description, organization=organization)
sys.exit()
Expand All @@ -113,7 +113,7 @@ def begin():

issue_number = None
try:
issue_number = int(args.get(1))
issue_number = args.get(1)
except:
pass
if issue_number is not None:
Expand All @@ -123,11 +123,15 @@ def begin():
elif args.get(2) == 'view':
view_issue(username, url, issue_number)
sys.exit(0)
elif args.get(1) == '--assigned':
get_issues(username, url, args.flags.contains(('--assigned', '-a')))
sys.exit(0)
else:
get_single_issue(username, url, issue_number)
sys.exit(0)
get_issues(username, url, args.flags.contains(('--assigned', '-a')))
sys.exit(0)
else:
get_issues(username, url, False)
sys.exit(0)

elif args.flags.contains(('--login', '-l')) or args.get(0) == 'login' :
if args.get(1) == None or args.get(2) == None:
Expand Down
23 changes: 16 additions & 7 deletions octogit/core.py
Expand Up @@ -24,6 +24,7 @@


ISSUES_ENDPOINT = 'https://api.github.com/repos/%s/%s/issues?page=%s'
CREATE_ISSUE_ENDPOINT = 'https://api.github.com/repos/%s/%s/issues'
SINGLE_ISSUE_ENDPOINT = 'https://api.github.com/repos/%s/%s/issues/%s'
ISSUES_PAGE = 'https://github.com/%s/%s/issues'
SINGLE_ISSUE_PAGE = 'https://github.com/%s/%s/issues/%s'
Expand All @@ -38,7 +39,6 @@ def valid_credentials():
else:
return False


def push_to_master():
push_master = 'git push -u origin master'
args = shlex.split(push_master)
Expand Down Expand Up @@ -147,7 +147,8 @@ def close_issue(user, repo, number):


def view_issue(user, repo, number):
"""Displays the specified issue in a browser
"""
Displays the specified issue in a browser
"""

github_view_url = SINGLE_ISSUE_PAGE % (user, repo, number)
Expand Down Expand Up @@ -237,7 +238,6 @@ def get_single_issue(user, repo, number):


def get_issues(user, repo, assigned=None):

github_issues_url = 'https://api.github.com/repos/%s/%s/issues' % (user, repo)

link = requests.head(github_issues_url).headers.get('Link', '=1>; rel="last"')
Expand All @@ -261,8 +261,18 @@ def get_issues(user, repo, assigned=None):
colored.red(data['message'])))
sys.exit(1)


if assigned:
data = filter(lambda i: i['assignee'] and i['assignee']['login'] == assigned, data)
for i in data:
print i['title']
try:
if i['assignee']['login'] == user:
pass
else:
data.remove(i)
except:
data.remove(i)


for issue in data:
#skip pull requests
Expand All @@ -271,13 +281,12 @@ def get_issues(user, repo, assigned=None):
width = [[colored.yellow('#'+str(issue['number'])), 4],]
if isinstance(issue['title'], unicode):
issue['title'] = issue['title'].encode('utf-8')
width.append([issue['title'], 65])
width.append([issue['title'], 90])
width.append([colored.red('('+ issue['user']['login']+')'), None])
print columns(*width)


def create_issue(user, repo, issue_name, description):

username = get_username()
password = get_password()

Expand All @@ -286,7 +295,7 @@ def create_issue(user, repo, issue_name, description):
colored.red('in order to create an issue, you need to login.')))
sys.exit(1)

post_url = ISSUES_ENDPOINT % (user, repo)
post_url = CREATE_ISSUE_ENDPOINT % (user, repo)
post_dict = {'title': issue_name, 'body': description}

r = requests.post(post_url, auth=(username, password), data=json.dumps(post_dict))
Expand Down

0 comments on commit 3f41e1c

Please sign in to comment.