Skip to content

Commit

Permalink
allowing for empty body (#6)
Browse files Browse the repository at this point in the history
* allowing for empty body
* update examples to not use set-env

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch authored Oct 16, 2020
1 parent 109fbc6 commit a815054
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
8 changes: 4 additions & 4 deletions examples/generate-opensource-interface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ jobs:
git commit -a -m "Automated deployment to update contributors $(date '+%Y-%m-%d')"
git push origin "${BRANCH_FROM}"
fi
echo "::set-env name=OPEN_PULL_REQUEST::${OPEN_PULL_REQUEST}"
echo "::set-env name=PULL_REQUEST_FROM_BRANCH::${BRANCH_FROM}"
echo "::set-env name=PULL_REQUEST_TITLE::[opensource-heartbeat] ${BRANCH_FROM}"
echo "::set-env name=PULL_REQUEST_BODY::OpenSource Heartbeat events update automated pull request."
echo "OPEN_PULL_REQUEST=${OPEN_PULL_REQUEST}" >> $GITHUB_ENV
echo "OPEN_PULL_REQUEST_FROM_BRANCH=${BRANCH_FROM}" >> $GITHUB_ENV
echo "PULL_REQUEST_TITLE=[opensource-heartbeat] ${BRANCH_FROM}" >> $GITHUB_ENV
echo "PULL_REQUEST_BODY=OpenSource Heartbeat events update automated pull request." >> $GITHUB_ENV
- name: Open Pull Request
uses: vsoch/[email protected]
Expand Down
32 changes: 15 additions & 17 deletions scripts/generate-events.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ def read_file(filename):


def get_users(users_file):
"""Given a users file, load it and return a list of users
"""
"""Given a users file, load it and return a list of users"""
users = []
if os.path.exists(users_file):
users = [u for u in read_file(users_file).split("\n") if u]
Expand Down Expand Up @@ -194,19 +193,16 @@ def generate_content(event, user, seen):
issue_state = event["payload"]["issue"]["state"]
issue_title = event["payload"]["issue"]["title"]
issue_body = event["payload"]["issue"]["body"].split("\n")[0] + "..."
description = (
"<a href='https://github.com/%s' target='_blank'>%s</a> %s issue <a href='%s' target='_blank'>%s#%s</a>.\n\n<p>%s</p><small>%s</small><a href='%s' target='_blank'>View Comment</a>"
% (
user,
user,
issue_state,
issue_url,
repo_name,
issue_number,
issue_title,
issue_body,
issue_url,
)
description = "<a href='https://github.com/%s' target='_blank'>%s</a> %s issue <a href='%s' target='_blank'>%s#%s</a>.\n\n<p>%s</p><small>%s</small><a href='%s' target='_blank'>View Comment</a>" % (
user,
user,
issue_state,
issue_url,
repo_name,
issue_number,
issue_title,
issue_body,
issue_url,
)
url = issue_url

Expand All @@ -228,7 +224,9 @@ def generate_content(event, user, seen):
url = comment_url

elif event_type == "PullRequestReviewEvent":
body = event["payload"]["review"]["body"].split("\n")[0] + "..."
body = event["payload"]["review"].get("body", "")
if body:
body = body.split("\n")[0] + "..."
url = event["payload"]["review"]["_links"]["html"]["href"]
pull_request_url = event["payload"]["pull_request"]["html_url"]
description = (
Expand Down Expand Up @@ -258,7 +256,7 @@ def generate_content(event, user, seen):

def write_events(events, output_dir):
"""Given a listing of events (associated with users) write them to markdown
files in the _events folder.
files in the _events folder.
"""
# We will only allow one PushEvent per user, and not rewrite files
seen = {}
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-users.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_parser():

def get_headers():
"""Get headers with an authentication token if one is found in the
environment
environment
"""
# Add token to increase API limits
token = os.environ.get("GITHUB_TOKEN")
Expand All @@ -69,7 +69,7 @@ def get_headers():

def search_users(query, search_type="users"):
"""Return a subset of users that match a particular query (up to 1000)
The example here searches for location Stanford
The example here searches for location Stanford
"""

url = "https://api.github.com/search/%s?q=%s" % (search_type, query)
Expand Down

0 comments on commit a815054

Please sign in to comment.