mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
This is just a safe fallback for local testing. If environment variables which activate the creation of the GitHub client aren't set, then the Local client is created. It acts on the most recent commit of the repo in the working directory. Minor edit to GitHubClient so that it raises an EnvironmentError exception if INPUT_GITHUB_URL environment variable is not defined. This allows main to detect the error and fall back to trying to use the Local client
17 lines
471 B
Python
17 lines
471 B
Python
import subprocess
|
|
|
|
class LocalClient(object):
|
|
def __init__(self):
|
|
self.diff_url = None
|
|
self.commits = ['placeholder'] # content doesn't matter, just length
|
|
self.insert_issue_urls = False
|
|
|
|
def get_last_diff(self):
|
|
return subprocess.run(['git', 'diff', 'HEAD^..HEAD'], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
|
|
def create_issue(self, issue):
|
|
return [201, None]
|
|
|
|
def close_issue(self, issue):
|
|
return 200
|