Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 35 additions & 3 deletions autoissue.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,33 @@ def injectNumber(issue, number):
with open(issue.fileName, 'w') as file:
file.writelines(data)

def identifyOrigin():
from settings import getValue, addProperty
val = getValue("provider")
if val is not None:
return val

origin = False
with open('.git/config') as f:
for line in f:
if "[remote \"origin\"]" in line:
origin = True
if "url = " in line and origin:
if "github.com" in line:
r = "github"
# elif "bitbucket" in line:
# r = "bitbucket"
origin = False

# Add to our settings file
if r:
addProperty("provider", r)
return r
else:
print("Unknown origin host")


def main():
from github import createIssues
parser = argparse.ArgumentParser(description="Auto-Issue-Creator argument parser")
parser.add_argument("-s", "--start", help="the token that begins the TODO: (ie. 'TODO')", default="TODO")
parser.add_argument("-d", "--debug", action='store_true', help="enable debug mode (no POSTing to github)")
Expand All @@ -190,18 +215,25 @@ def main():
basePath = os.path.abspath(os.path.expanduser(args['path']))
print "Base path of project:", basePath

provider = identifyOrigin()

issueList = getIssues()
print "Found {} {}:".format(len(issueList), "issue" if len(issueList) is 1 else "issues")

for issue in list(issueList):
print issue
if args["interactive"]:
post = raw_input('Create this issue in github? (y/n) ')
post = raw_input('Create this issue in {provider}? (y/n) '.format(provider=provider))
if post.lower() == 'n' or post.lower() == 'no':
issueList.remove(issue)

print "Creating {} issues".format(len(issueList))
createIssues(issueList, debug)

if (provider == "github"):
import github
github.createIssues(issueList, debug)
#elif provider == "bitbucket":
# print("Please implement me")

if __name__ == "__main__":
main()
19 changes: 1 addition & 18 deletions github.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import util
from autoissue import injectNumber
from urlparse import urljoin

from settings import addProperty, getValue, SETTINGS

API_URL = 'https://api.github.com'
SETTINGS = 'settings.williames' #settings file
HEADERS = {'Content-type':'application/json'}
TOKEN_KEY = 'auth_token'

Expand All @@ -35,22 +34,6 @@ def getToken():
print r.text
return None

def getValue(key):
if os.path.exists(SETTINGS):
with open(SETTINGS) as f:
for line in f:
if key in line:
return line.split(" ", 1)[1].strip(" \n")
return None

def addProperty(key, value):
with open(SETTINGS, "a+") as sett: # Will create the file if it does not exist
sett.write(key + " " + value + "\n")
return True

return False


def getRepo():
val = getValue("repo")

Expand Down
18 changes: 18 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

SETTINGS = 'settings.williames' #settings file

def getValue(key):
if os.path.exists(SETTINGS):
with open(SETTINGS) as f:
for line in f:
if key in line:
return line.split(" ", 1)[1].strip(" \n")
return None

def addProperty(key, value):
with open(SETTINGS, "a+") as sett: # Will create the file if it does not exist
sett.write(key + " " + value + "\n")
return True

return False