Python github.Github() Examples

The following are 30 code examples of github.Github(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module github , or try the search function .
Example #1
Source File: main.py    From Trending-Deep-Learning with MIT License 6 votes vote down vote up
def pandas_table_to_nested_list(df):
    """
    Converts pandas table df to nested list
    """
    table_data = [["" for x in range(df.shape[1])] for y in range(df.shape[0]+1)]
    
    # Columns names
    for i in range(df.shape[1]):
        table_data[0][i] = df.columns[i]
        
    for i in range(df.shape[0]):
        for j in range(df.shape[1]):
            table_data[i+1][j] = df.iat[i, j]
    
    return table_data
	
	
# Github object 
Example #2
Source File: server.py    From anonymous_github with MIT License 6 votes vote down vote up
def clean_github_repository(repo):
    """
    get the username/repository from a Github url
    :param repo:str the Github url of the repository
    :return: username/repository
    """
    if repo is None:
        return None
    repo = repo.replace("http://github.com/", "") \
        .replace("https://github.com/", "")
    if repo[-1] == '/':
        repo = repo[:-1]
    split_repo = repo.split("/")
    (username, repository) = split_repo[0:2]
    branch = "master"
    if len(split_repo) > 2:
        if split_repo[2] == "tree":
            branch = split_repo[3]
    return username, repository, branch 
Example #3
Source File: work_log.py    From Awesome-Scripts with MIT License 6 votes vote down vote up
def getRepos(self):
        """Get repos for user and add them in a combobox."""
        if self.ght.text() is not "":
            if self.parent is not None:
                self.parent.statusBar().showMessage('Fetching repos...')

            self.lbl.show()
            self.movie.start()
            self.ght.setStyleSheet(self.ght_original_style)
            token = self.ght.text()
            self.g = Github(token)

            try:
                if self.workThread is not None and self.workThread.isRunning():
                    return
            except AttributeError:
                pass
            finally:
                self.workThread = ConnectionThread(self, self.g, self.sig)
                self.workThread.start()

        else:
            self.ght.setStyleSheet("QLineEdit { border: 2px solid red; }") 
Example #4
Source File: server.py    From anonymous_github with MIT License 6 votes vote down vote up
def __init__(self,
                 github_token,
                 host="127.0.0.1",
                 port=5000,
                 config_dir='./repositories',
                 secret_key=None,
                 client_id=None,
                 client_secret=None):
        self.github_token = github_token if github_token != "" else os.environ["GITHUB_AUTH_TOKEN"]
        self.secret_key = secret_key if secret_key != "" else os.environ["SECRET_KEY"]
        self.client_id = client_id if client_id != "" else os.environ["GITHUB_CLIENT_ID"]
        self.client_secret = client_secret if client_secret != "" else os.environ["GITHUB_CLIENT_SECRET"]
        self.host = host
        self.port = port
        self.config_dir = config_dir
        if config_dir[0:2] == "./":
            self.config_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), config_dir[2:])
        if not os.path.exists(self.config_dir):
            os.makedirs(self.config_dir)
        self.application = self.create_flask_application()
        self.set_public_url()
        self.github = github.Github(login_or_token=self.github_token) 
Example #5
Source File: handler.py    From taskcat with Apache License 2.0 6 votes vote down vote up
def get_pending_builds(history):
    comments = {}
    repo = Github(get_token()).get_repo(GITHUB_REPO_NAME)
    prs = repo.get_pulls(state="open")
    for pr in prs:
        if pr.base.ref != "master":
            continue
        for comment in pr.get_issue_comments():
            if comment.id in history:
                continue
            if not comment_is_command(comment.body):
                continue
            if comment.user.login not in MAINTAINERS:
                LOG.warning(f"{comment.user.login} is not listed as a maintainer")
                continue
            if pr.number in comments:
                comments[pr.number]["comment_ids"].add(comment.id)
                continue
            comments[pr.number] = {
                "comment_ids": {comment.id},
                "pr_repo_name": pr.head.repo.full_name.split("/")[1],
                "pr_github_org": pr.head.repo.full_name.split("/")[0],
                "pr_branch": pr.head.ref,
            }
    return comments 
Example #6
Source File: utils.py    From commcare-cloud with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _get_github_credentials():
    if not env.tag_deploy_commits:
        return (None, None)
    try:
        from .config import GITHUB_APIKEY
    except ImportError:
        print((
            "You can add a config file to automate this step:\n"
            "    $ cp {project_root}/config.example.py {project_root}/config.py\n"
            "Then edit {project_root}/config.py"
        ).format(project_root=PROJECT_ROOT))
        username = input('Github username (leave blank for no auth): ') or None
        password = getpass('Github password: ') if username else None
        return (username, password)
    else:
        return (GITHUB_APIKEY, None) 
Example #7
Source File: connection.py    From insightconnect-plugins with MIT License 6 votes vote down vote up
def connect(self, params={}):
        self.logger.info("Connect: Connecting..")
        try:
            self.username = params.get('credentials').get("username")
            self.secret = params.get("credentials").get('password')
            self.basic_auth = (self.username, self.secret)
            self.github_session = requests.Session()
            self.github_user = github.Github(self.username, self.secret)
            user_info = self.github_user.get_user()
            self.user = self.github_user.get_user(self.username)
            self.github_session_user = requests.get(self.api_prefix, auth=(self.username, self.secret), verify=True)
            if str(self.github_session_user.status_code).startswith('2'):
                self.logger.info('Connect: Login successful')
            else:
                self.logger.info('Connect: Login unsuccessful')

        except github.GithubException as err:
            self.logger.error('Github: Connect: error %s', err.data)
            raise Exception('Github: Connect: user could not be authenticated please try again.')

        except requests.exceptions.RequestException as e:
            raise e 
Example #8
Source File: import_base.py    From RVD with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        # Authentication for user filing issue (must have read/write access to
        # repository to add issue to)
        try:
            self.token = os.environ['GITHUB_TOKEN'] 
        except KeyError:
            print("Make sure that you've GITHUB_TOKEN exported")
            exit(1)
        # First create a Github instance:
        # or using an access token
        self.g = Github(self.token)

    # def __init__(self, user, password):
    #     # TODO
    #     username = os.environ['GITHUB_USER']
    #     password = os.environ['GITHUB_USER'] 
Example #9
Source File: fork_conda_forge.py    From build-tools with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def fork_repo(gh, *, org, package_name, source_org):
    repo_full_name = f'{org.login}/{package_name}-feedstock'
    forked_repo = gh.get_repo(repo_full_name)
    print(f'Checking to see if {repo_full_name} exists on Github')
    try:
        # Check that the repo actually exists
        # Printing the name or any property of the repo issues this check
        print(f'{forked_repo.full_name} already exists, not forking it again.')
        return forked_repo
    except UnknownObjectException:
        print(f'{repo_full_name} does not exists on Github, will fork')
        pass

    # Else, now try to fork it from the origin
    feedstock_repo = gh.get_repo(f'{source_org}/{package_name}-feedstock')
    try:
        org.create_fork(feedstock_repo)
    except UnknownObjectException as e:
        if e.status == 404:
            raise RuntimeError(f'Repository not found: {e.data["message"]}')
        else:
            raise e 
Example #10
Source File: repo.py    From Penny-Dreadful-Tools with GNU General Public License v3.0 6 votes vote down vote up
def get_pull_requests(start_date: datetime.datetime,
                      end_date: datetime.datetime,
                      max_pull_requests: int = sys.maxsize,
                      repo_name: str = 'PennyDreadfulMTG/Penny-Dreadful-Tools'
                     ) -> List[PullRequest.PullRequest]:
    gh_user = configuration.get_optional_str('github_user')
    gh_pass = configuration.get_optional_str('github_password')
    if gh_user is None or gh_pass is None:
        return []
    g = Github(gh_user, gh_pass)
    git_repo = g.get_repo(repo_name)
    pulls: List[PullRequest.PullRequest] = []
    try:
        for pull in git_repo.get_pulls(state='closed', sort='updated', direction='desc'):
            if not pull.merged_at:
                continue
            merged_dt = dtutil.UTC_TZ.localize(pull.merged_at)
            updated_dt = dtutil.UTC_TZ.localize(pull.updated_at)
            if merged_dt > end_date:
                continue
            if updated_dt < start_date:
                return pulls
            pulls.append(pull)
            if len(pulls) >= max_pull_requests:
                return pulls
    except RequestException as e:
        print('Github pulls error (request)', e)
    except GithubException as e:
        print('Gihub pulls error (github)', e)
    return pulls 
Example #11
Source File: ontologies_filter.py    From OnToology with Apache License 2.0 6 votes vote down vote up
def ontologies_for_repo(repo):
    """
    :param repo: repo string as "user/reponame"
    :return: ontologies list
    """
    g = Github(os.environ['github_username'], os.environ['github_password'])
    try:
        repo = g.get_repo(repo)
        files_and_dirs = repo.get_file_contents('/')
        files_and_dirs = [fd for fd in files_and_dirs if fd.name != 'OnToology']
        # for fd in files_and_dirs:
        #     print fd.name + ' => ' + fd.type
        ontologies = []
        for fd in files_and_dirs:
            ontos = get_ontologies(fd, repo)
            ontologies += ontos
        return ontologies
    except Exception as e:
        print str(e)
        return [] 
Example #12
Source File: autoncore.py    From OnToology with Apache License 2.0 6 votes vote down vote up
def fork_repo(target_repo):
    """
    :param target_repo: username/reponame
    :return: forked repo (e.g. OnToologyUser/reponame)
    """
    # the wait time to give github sometime so the repo can be forked
    # successfully
    time.sleep(sleeping_time)
    # this is a workaround and not a proper way to do a fork
    # comm = "curl --user \"%s:%s\" --request POST --data \'{}\' https://api.github.com/repos/%s/forks" % (
    #     username, password, target_repo)
    # if not settings.test_conf['local']:
    #     comm += ' >> "' + log_file_dir + '"'
    # dolog(comm)
    # call(comm, shell=True)
    username = os.environ['github_username']
    password = os.environ['github_password']
    gg = Github(username, password)
    repo = gg.get_repo(target_repo)
    user = gg.get_user()
    forked_repo = user.create_fork(repo)
    dolog('forked to: ' + forked_repo.name)
    return forked_repo 
Example #13
Source File: engine.py    From GSIL with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, token):
        """
        GitHub engine
        """
        self.token = token
        self.g = Github(login_or_token=token, per_page=per_page)
        self.rule_object = None
        self.code = ''
        # jquery/jquery
        self.full_name = ''
        self.sha = ''
        self.url = ''
        # src/attributes/classes.js
        self.path = ''

        self.result = None
        # 被排除掉的结果,为防止误报,将发送邮件人工核查
        self.exclude_result = None
        self.hash_list = None
        self.processed_count = None
        self.next_count = None 
Example #14
Source File: automate_project.py    From project-automation with MIT License 6 votes vote down vote up
def CreateGitHubRepo():
    global repoName
    global private
    global username
    global password
    GetCredentials()
    try:
        user = Github(username, password).get_user()
        user.create_repo(repoName, private=private)
        return True
    except Exception as e:
        repoName = ""
        username = ""
        password = ""
        private = ""
        print(Fore.RED + str(e) + Fore.WHITE)
        return False 
Example #15
Source File: fileLoaders.py    From grlc with MIT License 6 votes vote down vote up
def __init__(self, user, repo, subdir=None, sha=None, prov=None):
        """Create a new GithubLoader.

        Keyword arguments:
        user -- Github user name of the target github repo.
        repo -- Repository name of the target github repo.
        subdir -- Target subdirectory within the given repo. (default: None).
        sha -- Github commit identifier hash (default: None).
        prov -- grlcPROV object for tracking provenance (default: None)."""
        self.user = user
        self.repo = repo
        self.subdir = subdir
        self.sha = sha
        self.prov = prov
        gh = Github(static.ACCESS_TOKEN)
        try:
            self.gh_repo = gh.get_repo(user + '/' + repo, lazy=False)
        except BadCredentialsException:
            raise Exception('BadCredentials: have you set up github_access_token on config.ini ?')
        except Exception:
            raise Exception('Repo not found: ' + user + '/' + repo) 
Example #16
Source File: api_views.py    From OnToology with Apache License 2.0 6 votes vote down vote up
def login(request):
    if request.method == 'POST':
        if 'username' not in request.POST or 'password' not in request.POST:
            return JsonResponse({'message': 'username or password is missing'}, status=400)
        username = request.POST['username']
        token = request.POST['password']  # or token
        g = Github(username, token)
        try:
            g.get_user().login
            try:
                user = OUser.objects.get(username=username)
                if user.token_expiry <= datetime.now():
                    sec = ''.join([random.choice(string.ascii_letters + string.digits) for _ in range(9)])
                    while len(OUser.objects.filter(token=sec)) > 0:  # to ensure a unique token
                        sec = ''.join([random.choice(string.ascii_letters + string.digits) for _ in range(9)])
                    user.token = sec
                    user.token_expiry = datetime.now() + timedelta(days=1)
                    user.save()
                return JsonResponse({'token': user.token})
            except Exception as e:
                return JsonResponse({'message': 'authentication error'}, status=401)
        except Exception as e:
            return JsonResponse({'message': 'authentication error'}, status=401)
    return JsonResponse({'message': 'Invalid method'}, status=405) 
Example #17
Source File: test_pr_comment.py    From packit-service with MIT License 6 votes vote down vote up
def mock_pr_comment_functionality(request):
    packit_yaml = (
        "{'specfile_path': '', 'synced_files': [], 'jobs': " + str(request.param) + "}"
    )
    flexmock(
        GithubProject,
        full_repo_name="packit-service/hello-world",
        get_file_content=lambda path, ref: packit_yaml,
        get_web_url=lambda: "https://github.com/the-namespace/the-repo",
        get_pr=lambda pr_id: flexmock(head_commit="12345"),
    )
    flexmock(Github, get_repo=lambda full_name_or_id: None)

    config = ServiceConfig()
    config.command_handler_work_dir = SANDCASTLE_WORK_DIR
    flexmock(ServiceConfig).should_receive("get_service_config").and_return(config)
    trigger = flexmock(
        job_config_trigger_type=JobConfigTriggerType.pull_request, id=123
    )
    flexmock(AddPullRequestDbTrigger).should_receive("db_trigger").and_return(trigger)
    flexmock(PullRequestModel).should_receive("get_by_id").with_args(123).and_return(
        trigger
    )
    flexmock(LocalProject, refresh_the_arguments=lambda: None)
    flexmock(Whitelist, check_and_report=True) 
Example #18
Source File: autoncore.py    From OnToology with Apache License 2.0 5 votes vote down vote up
def update_g(token):
    global g
    g = Github(token) 
Example #19
Source File: test_release_event.py    From packit-service with MIT License 5 votes vote down vote up
def test_dist_git_push_release_handle_multiple_branches(
    github_release_webhook, fedora_branches
):
    packit_yaml = (
        "{'specfile_path': 'hello-world.spec', 'synced_files': []"
        ", jobs: [{trigger: release, job: propose_downstream, "
        "metadata: {targets:[], dist-git-branch: fedora-all}}]}"
    )
    flexmock(Github, get_repo=lambda full_name_or_id: None)
    project = flexmock(
        get_file_content=lambda path, ref: packit_yaml,
        full_repo_name="packit-service/hello-world",
        repo="hello-world",
        get_files=lambda ref, filter_regex: [],
        get_sha_from_tag=lambda tag_name: "123456",
        get_web_url=lambda: "https://github.com/packit-service/hello-world",
        is_private=lambda: False,
    )
    flexmock(LocalProject, refresh_the_arguments=lambda: None)
    flexmock(Whitelist, check_and_report=True)
    config = ServiceConfig()
    config.command_handler_work_dir = SANDCASTLE_WORK_DIR
    config.get_project = lambda url: project
    flexmock(ServiceConfig).should_receive("get_service_config").and_return(config)
    # it would make sense to make LocalProject offline
    for branch in fedora_branches:
        flexmock(PackitAPI).should_receive("sync_release").with_args(
            dist_git_branch=branch, version="0.3.0"
        ).once()

    flexmock(FedPKG).should_receive("clone").and_return(None)

    flexmock(AddReleaseDbTrigger).should_receive("db_trigger").and_return(
        flexmock(job_config_trigger_type=JobConfigTriggerType.release, id=123)
    )

    results = SteveJobs().process_message(github_release_webhook)
    assert first_dict_value(results["jobs"])["success"]
    assert results["event"]["trigger"] == "release" 
Example #20
Source File: autoncore.py    From OnToology with Apache License 2.0 5 votes vote down vote up
def update_file(target_repo, path, message, content, branch=None):
    global g
    username = os.environ['github_username']
    password = os.environ['github_password']
    g = Github(username, password)
    repo = g.get_repo(target_repo)
    if branch is None:
        sha = repo.get_file_contents(path).sha
        dolog('default branch with file sha: %s' % str(sha))
    else:
        sha = repo.get_file_contents(path, branch).sha
        dolog('branch %s with file %s sha: %s' % (branch, path, str(sha)))
    apath = path
    if apath[0] != "/":
        apath = "/" + apath.strip()
    dolog("username: " + username)
    dolog('will update the file <%s> on repo<%s> with the content <%s>,  sha <%s> and message <%s>' %
          (apath, target_repo, content, sha, message))
    dolog("repo.update_file('%s', '%s', \"\"\"%s\"\"\" , '%s' )" % (apath, message, content, sha))
    for i in range(3):
        try:
            if branch is None:
                repo.update_file(apath, message, content, sha)
            else:
                repo.update_file(apath, message, content, sha, branch=branch)
            dolog('file updated')
            return
        except:
            dolog('chance #%d file update' % i)
            time.sleep(1)
    dolog('after 10 changes, still could not update ')
    # so if there is a problem it will raise an exception which will be captured by the calling function
    repo.update_file(apath, message, content, sha) 
Example #21
Source File: autoncore.py    From OnToology with Apache License 2.0 5 votes vote down vote up
def init_g():
    global g
    username = os.environ['github_username']
    password = os.environ['github_password']
    g = Github(username, password) 
Example #22
Source File: github.py    From cms with GNU General Public License v3.0 5 votes vote down vote up
def addUser(self):
        GITHUB_TOKEN = Token.objects.values().get(key='GITHUB_TOKEN')['value']
        g = Github(GITHUB_TOKEN)
        ghuser = g.get_user(self.username)
        org = g.get_organization('amfoss')
        if not org.has_in_members(ghuser):
            org.add_to_members(ghuser, 'member') 
Example #23
Source File: github.py    From cms with GNU General Public License v3.0 5 votes vote down vote up
def removeUser(self):
        GITHUB_TOKEN = Token.objects.values().get(key='GITHUB_TOKEN')['value']
        g = Github(GITHUB_TOKEN)
        ghuser = g.get_user(self.username)
        org = g.get_organization('amfoss')
        if org.has_in_members(ghuser):
            org.remove_from_members(ghuser) 
Example #24
Source File: utils.py    From commcare-cloud with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _get_github():
    login_or_token, password = _get_github_credentials()
    if env.tag_deploy_commits and not login_or_token:
        print(magenta(
            "Warning: Creation of release tags is disabled. "
            "Provide Github auth details to enable release tags."
        ))
    return Github(login_or_token=login_or_token, password=password) 
Example #25
Source File: defaulttriager.py    From ansibullbot with GNU General Public License v3.0 5 votes vote down vote up
def _connect(self):
        """Connects to GitHub's API"""
        if self.github_token:
            return Github(base_url=self.github_url, login_or_token=self.github_token)
        else:
            return Github(
                base_url=self.github_url,
                login_or_token=self.github_user,
                password=self.github_pass
            ) 
Example #26
Source File: test_issue_comment.py    From packit-service with MIT License 5 votes vote down vote up
def mock_issue_comment_functionality():
    packit_yaml = (
        "{'specfile_path': 'packit.spec', 'synced_files': [],"
        "'jobs': [{'trigger': 'release', 'job': 'propose_downstream',"
        "'metadata': {'dist-git-branch': 'master'}}],"
        "'downstream_package_name': 'packit'}"
    )
    flexmock(
        GithubProject,
        get_file_content=lambda path, ref: packit_yaml,
        full_repo_name="packit-service/packit",
    )
    flexmock(Github, get_repo=lambda full_name_or_id: None)
    (
        flexmock(GithubProject)
        .should_receive("can_merge_pr")
        .with_args("phracek")
        .and_return(True)
    )
    flexmock(GithubProject).should_receive("issue_comment").and_return(None)
    flexmock(GithubProject).should_receive("issue_close").and_return(None)
    gr = GithubRelease(
        tag_name="0.5.1",
        url="packit-service/packit",
        created_at="",
        tarball_url="https://foo/bar",
        git_tag=flexmock(GitTag),
        project=flexmock(GithubProject),
        raw_release=flexmock(PyGithubRelease),
    )
    flexmock(GithubProject).should_receive("get_releases").and_return([gr])
    config = ServiceConfig()
    config.command_handler_work_dir = SANDCASTLE_WORK_DIR
    flexmock(ServiceConfig).should_receive("get_service_config").and_return(config)
    flexmock(LocalProject, refresh_the_arguments=lambda: None)
    flexmock(Whitelist, check_and_report=True) 
Example #27
Source File: utils.py    From commcare-cloud with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def tag_setup_release(self):
        if _github_auth_provided():
            try:
                self.repo.create_git_ref(
                    ref='refs/tags/' + '{}-{}-setup_release'.format(self.timestamp, self._environment),
                    sha=self.deploy_ref,
                )
            except UnknownObjectException:
                raise Exception(
                    'Github API key does not have the right settings. '
                    'Please create an API key with the public_repo scope enabled.'
                )
            return True
        return False 
Example #28
Source File: fork_conda_forge.py    From build-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def get_github_token(token_dir):
    try:
        github_token_filename = (token_dir / 'github.token').expanduser()
        with open(github_token_filename, 'r') as fh:
            github_token = fh.read().strip()
        if not github_token:
            raise ValueError()
        return github_token
    except (IOError, ValueError):
        raise RuntimeError(
            'No github token found for archiconda on Github. \n'
            'Go to https://github.com/settings/tokens/new and generate\n'
            f'a token with repo access. Put it in {github_token_filename}') 
Example #29
Source File: test_release_event.py    From packit-service with MIT License 5 votes vote down vote up
def test_dist_git_push_release_handle(github_release_webhook):
    packit_yaml = (
        "{'specfile_path': 'hello-world.spec', 'synced_files': []"
        ", jobs: [{trigger: release, job: propose_downstream, metadata: {targets:[]}}]}"
    )
    flexmock(Github, get_repo=lambda full_name_or_id: None)
    project = flexmock(
        get_file_content=lambda path, ref: packit_yaml,
        full_repo_name="packit-service/hello-world",
        repo="hello-world",
        get_files=lambda ref, filter_regex: [],
        get_sha_from_tag=lambda tag_name: "123456",
        get_web_url=lambda: "https://github.com/packit-service/hello-world",
        is_private=lambda: False,
    )
    flexmock(LocalProject, refresh_the_arguments=lambda: None)
    flexmock(Whitelist, check_and_report=True)
    config = ServiceConfig()
    config.command_handler_work_dir = SANDCASTLE_WORK_DIR
    config.get_project = lambda url: project
    flexmock(ServiceConfig).should_receive("get_service_config").and_return(config)
    # it would make sense to make LocalProject offline
    flexmock(PackitAPI).should_receive("sync_release").with_args(
        dist_git_branch="master", version="0.3.0"
    ).once()

    flexmock(AddReleaseDbTrigger).should_receive("db_trigger").and_return(
        flexmock(job_config_trigger_type=JobConfigTriggerType.release, id=123)
    )

    results = SteveJobs().process_message(github_release_webhook)
    assert first_dict_value(results["jobs"])["success"]
    assert results["event"]["trigger"] == "release" 
Example #30
Source File: test_steve.py    From packit-service with MIT License 5 votes vote down vote up
def test_process_message(event):
    packit_yaml = {
        "specfile_path": "bar.spec",
        "synced_files": [],
        "jobs": [{"trigger": "release", "job": "propose_downstream"}],
    }

    flexmock(Github, get_repo=lambda full_name_or_id: None)
    flexmock(
        GithubProject,
        get_file_content=lambda path, ref: dumps(packit_yaml),
        full_repo_name="foo/bar",
        get_files=lambda ref, filter_regex: [],
        get_sha_from_tag=lambda tag_name: "12345",
        get_web_url=lambda: "https://github.com/the-namespace/the-repo",
        is_private=lambda: False,
    )
    flexmock(LocalProject, refresh_the_arguments=lambda: None)
    config = ServiceConfig()
    config.command_handler_work_dir = SANDCASTLE_WORK_DIR
    flexmock(ServiceConfig).should_receive("get_service_config").and_return(config)
    flexmock(PackitAPI).should_receive("sync_release").with_args(
        dist_git_branch="master", version="1.2.3"
    ).once()
    flexmock(AddReleaseDbTrigger).should_receive("db_trigger").and_return(
        flexmock(job_config_trigger_type=JobConfigTriggerType.release, id=1)
    )
    flexmock(Whitelist, check_and_report=True)
    results = SteveJobs().process_message(event)
    j = first_dict_value(results["jobs"])
    assert "propose_downstream" in next(iter(results["jobs"]))
    assert j["success"]
    assert results["event"]["trigger"] == "release"