-
Notifications
You must be signed in to change notification settings - Fork 4
Changed so pr can now take in URL as well as pr number. #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 87 commits
7154e1b
10b8fde
61c6ad0
27fe7aa
34a28b9
78ff0f9
af87d2c
6c73f8b
a323c90
ffbd8e9
c533dbf
7e71972
b210743
dd7d585
ea818c5
dfee42a
c0f5d58
f82ffad
15300c1
5268d5a
2ad6540
d3fe459
31a4bcc
812d522
988b3c6
2a1e2dd
7521448
87f8219
a03ecea
e305cfc
d4ce7e0
cc8f2bc
354c60f
34b045c
f26026c
570cf2a
c38247f
0e8f2f2
22a9d9e
37e47bd
4732510
abf7478
13d07f9
1265f9f
368f173
214c60e
0fdc94d
abfe5f8
d5650b8
4d74218
8db6e51
2e4879a
d1b65cd
5a2b97d
b687d70
d80c7b9
373bbd4
e7cb367
26b2e91
2374eb6
670ae29
5fb25b0
9dc9443
acdb899
abf9469
ab83932
b212b8c
418a162
f758564
9e9741d
b50da92
f8c8bd6
5ed7992
3b6856c
943f18a
79fd1f7
961e5d5
59628b6
5799bb2
84a63e9
5fcc3e9
1becefe
0fd5122
f1ddf19
9172836
e71d65a
b254f66
ab5ef22
39c2f4f
b814a5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ def login(): | |
| For example consider running 'git remote -v' and getting back: | ||
| origin git@github.com:test_user/test_repo.git (fetch) | ||
| origin git@github.com:test_user/test_repo.git (push) | ||
|
|
||
| Returns | ||
| ------- | ||
| username : string | ||
|
|
@@ -30,7 +29,6 @@ def login(): | |
| origin repository of the github user, i.e. test_repo | ||
| remotes : string | ||
| Git remotes: the output of 'git remote -v' | ||
|
|
||
| """ | ||
| process = subprocess.Popen(["git", "remote", "-v"], stdout=subprocess.PIPE) | ||
| remotes = str(process.stdout.read()) | ||
|
|
@@ -44,7 +42,6 @@ def login(): | |
|
|
||
| def get_token(): | ||
| """Retrieve token from configuration file. | ||
|
|
||
| Returns | ||
| ------- | ||
| token : string | ||
|
|
@@ -63,27 +60,21 @@ def get_token(): | |
| else: | ||
| print(textwrap.dedent("""\ | ||
| No authentication token specified in: ~/.config/git-hub.yaml | ||
|
|
||
| Please see | ||
|
|
||
| https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ | ||
|
|
||
| for instruction on obtaining a token. Then update the configuration | ||
| file as follows: | ||
|
|
||
| token = abc123 | ||
| """)) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| def pr(num): | ||
| """Pulls down and checkout the branch of the pr. | ||
|
|
||
| This will run the following commands in the terminal: | ||
| "git remote add user git@github.com:user/repo", | ||
| "git fetch user", | ||
| "git checkout -b pr/num user/branch" | ||
|
|
||
| Parameters | ||
| ---------- | ||
| num : integer | ||
|
|
@@ -122,10 +113,8 @@ def pr(num): | |
|
|
||
| def push(): | ||
| """Pushes changes back to a branch. | ||
|
|
||
| This will run the following command: | ||
| "git push user pr/num:branch" | ||
|
|
||
| """ | ||
| p = subprocess.Popen(["git", "branch"], stdout=subprocess.PIPE) | ||
| pr = str(p.stdout.read()) | ||
|
|
@@ -170,7 +159,6 @@ def path_to_toml(): | |
|
|
||
| def find_in_dictionary(pr_id, pr_data): | ||
| """Fetches all the information on a certain PR | ||
|
|
||
| Parameters | ||
| ---------- | ||
| pr_id : integer | ||
|
|
@@ -187,7 +175,6 @@ def find_in_dictionary(pr_id, pr_data): | |
|
|
||
| def get_info(pr_data): | ||
| """Fetches all the information on a certain PR | ||
|
|
||
| Parameters | ||
| ---------- | ||
| pr_data : integer | ||
|
|
@@ -237,7 +224,6 @@ def get_info(pr_data): | |
| def parse_time(time): | ||
| """ | ||
| Converts time into python datetime object | ||
|
|
||
| Parameters | ||
| ---------- | ||
| time : String | ||
|
|
@@ -259,7 +245,6 @@ def parse_time(time): | |
| def print_in_order(dict, increasing=False): | ||
| """ | ||
| Prints items in q sorted by order given by sort | ||
|
|
||
| Parameters | ||
| ---------- | ||
| Q : PriorityQueue | ||
|
|
@@ -281,7 +266,6 @@ def find_match(open_or_closed, list_of_dictionaries, | |
| keyword, user, comment, number, branch, label): | ||
| """Helper function that finds all matches in the | ||
| given dictionary that fits the specified parameters. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| open_or_closed : boolean | ||
|
|
@@ -298,7 +282,6 @@ def find_match(open_or_closed, list_of_dictionaries, | |
| Search by PR number | ||
| branch : string | ||
| Search by PR branch | ||
|
|
||
| Returns | ||
| ---------- | ||
| appeared_before : boolean | ||
|
|
@@ -352,9 +335,7 @@ def find_match(open_or_closed, list_of_dictionaries, | |
| def search(keyword, user, comment, number, | ||
| branch, opened_or_closed, label, sort): | ||
| """Searches open and closed pull request comments for specified keyword. | ||
|
|
||
| Opens pull-requests.toml file in .git folder to fetch pull requests. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| keyword : string | ||
|
|
@@ -400,7 +381,6 @@ def search(keyword, user, comment, number, | |
| def find_pr_info(username, repo, pr, token, open_or_closed): | ||
| """Helper function that finds all the information we want to record from the | ||
| pull requests from the API and converts it to toml format syntax | ||
|
|
||
| Parameters | ||
| ---------- | ||
| username : string | ||
|
|
@@ -471,7 +451,6 @@ def find_issue_info(username, repo, issue, token): | |
| """Helper function that finds all the information | ||
| we want to record from the issues | ||
| from the API and converts it to toml format syntax. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| username : string | ||
|
|
@@ -557,7 +536,8 @@ def render(): | |
| try: | ||
| plot_pr.execute() | ||
| except ImportError: | ||
| print("Matplotlib not installed, cannot render image. Continuing without image.") | ||
| print("Matplotlib not installed, cannot render image.") | ||
| print("Continuing without image.") | ||
| app.main() | ||
|
|
||
|
|
||
|
|
@@ -580,7 +560,12 @@ def cli(): | |
| @click.option('--label', '-l', default="", help="search PR by label") | ||
| def hub(command, args, user, comment, number, branch, sort, opened, label): | ||
| if command == "pr": | ||
| pr_num = int(args[0]) | ||
| # if user inputs the pull request number | ||
| if args[0].isdigit(): | ||
| pr_num = int(args[0]) | ||
| # if user inputs the url of the pull request | ||
| else: | ||
| pr_num = int(args[0].split('/')[-1]) | ||
|
||
| pr(pr_num) | ||
|
|
||
| elif command == "push": | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ pyyaml | |
| click | ||
| toml | ||
| requests | ||
| jinja2 | ||
| jinja2 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this code doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks if the argument supplied is an integer (so either the pr number(i.e. 4) or the url(e.g. #35)) so that it knows whether to take it as an integer or to find the pr number inside the url.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It changed the url I inputted into my comment. But like if the user inputted instead of '30', they inputted 'https://github.com/machine-shop/oss_devkit/pull/ 30'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I suggest adding comments to both branches of the "if", saying what you're expecting in each branch. This will help future developers see what you're doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added comments.