Skip to content

Instantly share code, notes, and snippets.

View grantmcconnaughey's full-sized avatar

Grant McConnaughey grantmcconnaughey

View GitHub Profile
syntax on
filetype indent on
set number
set autoindent
set tabstop=4
set expandtab
set shiftwidth=4
highlight LineNr ctermfg=grey
@grantmcconnaughey
grantmcconnaughey / gitconfig
Last active March 14, 2016 15:03
My .gitconfig
[user]
name = Grant McConnaughey
email = grantmcconnaughey@gmail.com
[color]
ui = true
[core]
excludesfile = ~/.gitignore_global
autocrlf = input
[alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
def lint_entire_project(self, local_repo_path):
"""Runs quality checks on the local repo and returns the output as a string."""
self.state = BUILD_RUNNING
self.save()
process = subprocess.Popen(['flake8', local_repo_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=False)
def __init__(self):
self.linter = self.get_linter()
def lint_entire_project(self):
"""Lints the local repo and returns the violations found."""
self.state = BUILD_RUNNING
self.save()
violations = self.linter.lint()
@login_required
def dashboard(request, service):
projects = request.user.get_projects(service)
return render(request, 'project/dashboard.html', {'projects': projects})
<a href="{% url "project:add_projects" "gh" %}" class="btn btn-primary">
<em class="icon-plus"></em> Add Projects
</a>
# Future git services will go here
GITHUB = 'gh'
DUMMY = 'dummy'
def service(request):
services = (GITHUB, DUMMY)
the_service = None
for _service in services:
if request.path.startswith('/{}/'.format(_service)):
the_service = _service
<a href="{% url "project:add_projects" service %}" class="btn btn-primary">
<em class="icon-plus"></em> Add Projects
</a>
def get_projects(self):
client = Github(self.access_token)
owner_logins = set(org.login for org in client.get_user().get_orgs())
owner_logins.add(self.username)
return Project.objects.filter(owner__login__in=owner_logins)
# This dict lives in its own file
git_clients = {
GITHUB: GitHubBackend,
DUMMY: DummyGitBackend
}
def get_projects(self, service):
# Dynamic based on the service
GitBackend = git_clients[service]
git_client = GitBackend(user=self)