Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Git TipWhy is it useful?
To ignore whitespace in a Git diff: add ?w=1 to the URL

Find this and other GitHub secrets at https://github.com/blog/967-github-secrets

Push changes to your fork... often.If you accidentally trash your local repo, all is not lost.

Always update your branch via the rebase route.  Never use the "Update Branch" button on GitHub.

Whenever your branch is out of date, there's a button that appears on your PR on Github saying "Update Branch" which tempts you to bring your branch up to date with master with the click of a button. Well, please don't give in to the temptation, that button will create a merge commit, which is not signed, both of which are forbidden. So, always update your branch via the painful, rebase route.
When reviewing new files larger than 1500 lines, put each comment with its line number into one large comment in the pull request.

One developer has been bitten twice by large GitHub reviews.  In both cases he was reviewing new files that were larger than 1500 lines.  Any comment that he gave after line 1500 showed up at line 1500. 

To recover info that's not accessible via the website

GitHub has a Python API called PyGithub. You can use it to access comments from a PR that is not responsive. The script is attached here. You can pretty much recover everything from a GitHub PR using this API; this script just recovers the comments (along with the code diff hunk):


'''
Created on Jan 9, 2018

@author: ragrawal
'''

from github import Github

# Add your pull request number here
PR = -1

# Github Access token
TOKEN = ""

# or using an access token
g = Github(TOKEN)
if g is None:
raise Exception("Github token invalid, couldn't login")

pbspro_repo = None
# Then play with your Github objects:
for repo in g.get_user().get_repos():
if repo.name == "pbspro":
pbspro_repo = repo

if pbspro_repo is None:
raise Exception("PBSPro repo not found")

pr_object = pbspro_repo.get_pull(PR)
if pr_object is None:
raise Exception("Pull Request " + str(PR) + " not found")

comments = pr_object.get_comments()
if comments is None:
print "No comments found on PR " + str(PR) + ", exiting"
exit(0)

filename = "pr_" + str(PR) + "_review_comments"
with open(filename, "w") as fd:
for comment in comments:
fd.write(comment.commit_id + "\n" + str(comment.created_at))
fd.write("\n" + comment.user.name + "\n")
fd.write("FILENAME: " + comment.path + ": " + str(comment.position) + "\n")
fd.write("COMMENT:\n" + comment.body + "\n")
fd.write("DIFF: \n" + comment.diff_hunk + "\n\n")
fd.write("==================\n\n")

print "PR comments written in " + filename




...

Site Map

Developer Guide Pages

...