c.execute('''INSERT INTO config VALUES ('', '')''')
conn.commit()
conn.close()
@ganarchy.command()
@click.argument('commit')
defset_commit(commit):
"""Sets the commit that represents the project"""
importre
ifnotre.fullmatch("[a-fA-F0-9]{40}",commit):
raiseclick.BadArgumentUsage("COMMIT must be a git commit hash")
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''UPDATE config SET git_commit=?''',(commit,))
conn.commit()
conn.close()
@ganarchy.command()
@click.argument('project-title')
defset_project_title(project_title):
"""Sets the project title"""
importre
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''UPDATE config SET project_title=?''',(project_title,))
conn.commit()
conn.close()
@ganarchy.group()
defrepo():
"""Modifies repos to track"""
@repo.command()
@click.argument('url')
defadd(url):
"""Adds a repo to track"""
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''INSERT INTO repos VALUES (?, 0)''',(url,))
conn.commit()
conn.close()
@repo.command()
@click.argument('url')
defenable(url):
"""Enables tracking of a repo"""
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''UPDATE repos SET active=1 WHERE url=?''',(url,))
conn.commit()
conn.close()
@repo.command()
@click.argument('url')
defdisable(url):
"""Disables tracking of a repo"""
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''UPDATE repos SET active=0 WHERE url=?''',(url,))
conn.commit()
conn.close()
@repo.command()
@click.argument('url')
defremove(url):
"""Stops tracking a repo"""
click.confirm("WARNING: This operation does not delete the commits associated with the given repo! Are you sure you want to continue? This operation cannot be undone.")
conn=sqlite3.connect(data_home+"/ganarchy.db")
c=conn.cursor()
c.execute('''DELETE FROM repos WHERE url=?''',(url,))
c.execute('''DELETE FROM repo_history WHERE url=?''',(url,))