Skip to content
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

User can assign him/herself to issue when pushing a new branch. #59

Conversation

StevenXL
Copy link

@StevenXL StevenXL commented Feb 28, 2019

Resolves #15

@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from 035599d to 32d4398 Compare February 28, 2019 22:24
@vrom911 vrom911 requested review from vrom911 and chshersh March 1, 2019 01:40
@vrom911 vrom911 added enhancement New feature or request GitHub GitHub API CLI command-line interface labels Mar 1, 2019
Copy link
Member

@vrom911 vrom911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start!

src/Hit/Cli.hs Outdated Show resolved Hide resolved
src/Hit/Git.hs Outdated Show resolved Hide resolved
src/Hit/Git.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from 32d4398 to fbf9635 Compare March 1, 2019 15:13
Copy link
Member

@vrom911 vrom911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! But I see one problem: we now get the issue info twice in the new command. I would like to avoid that and to reuse the issue info that is fetched in the new command anyway. That means that in attempAssigment you don't need to use issue' function.

src/Hit/Git.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
stack.yaml Outdated Show resolved Hide resolved
@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch 3 times, most recently from da08c53 to a42950d Compare March 6, 2019 01:16
@StevenXL
Copy link
Author

StevenXL commented Mar 6, 2019

@vrom911 Please let me know what you think. :-)

Copy link
Member

@vrom911 vrom911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StevenXL , unfortunately, it doesn't work for me. Did you have a chance to test it somehow?

Also, I noticed that a bunch of old behaviour is broken now. From what I noticed the issues displayed in a different way know. I continue to test what else is broken now.

@chshersh, we need some tests asap, cause I'm sure this is because of the new version of the GitHub. The token is not working for me now, I don't know why.

@chshersh
Copy link
Contributor

chshersh commented Mar 6, 2019

@vrom911 @StevenXL When I call new <n> -a command I see the following error:

ParseError "Error in $: key \"updated_at\" not present"

This doesn't work for me either, unfortunately 😞

Regarding tests: need to think how to make tests automatic. Maybe not for all commands. But should be possible. At least for issue command. Maybe we can create test repository only to test hit-on. But even without the repository it should be possible do test some commands...

@StevenXL
Copy link
Author

StevenXL commented Mar 6, 2019

Hm... I think this exposes a problem with the github library.

For example, if I run hit new 99, and there is no issue 99 in the repo, with github-0.20, I would get the following output:

  HTTPError (HttpExceptionRequest Request {
  host                 = "api.github.com"
  port                 = 443
  secure               = True
  requestHeaders       = [("Authorization","<REDACTED>"),("User-Agent","github.hs/0.7.4"),("Accept","application/vnd.github.preview")]
  path                 = "/repos/StevenXL/hit-on/issues/99"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","GitHub.com"),("Date","Wed, 06 Mar 2019 18:31:42 GMT"),("Content-Type","application/json; charset=utf-8"),("Transfer-Encoding","chunked"),("Status","404 Not Found"),("X-RateLimit-Limit","5000"),("X-RateLimit-Remaining","4999"),("X-RateLimit-Reset","1551900702"),("X-OAuth-Scopes","admin:business, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion"),("X-Accepted-OAuth-Scopes","repo"),("X-GitHub-Media-Type","github.v3; param=preview"),("Access-Control-Expose-Headers","ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type"),("Access-Control-Allow-Origin","*"),("Strict-Transport-Security","max-age=31536000; includeSubdomains; preload"),("X-Frame-Options","deny"),("X-Content-Type-Options","nosniff"),("X-XSS-Protection","1; mode=block"),("Referrer-Policy","origin-when-cross-origin, strict-origin-when-cross-origin"),("Content-Security-Policy","default-src 'none'"),("Content-Encoding","gzip"),("X-GitHub-Request-Id","0A2F:403A:900CD5:11B977A:5C80120E")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "{\"message\":\"Not Found\",\"documentation_url\":\"https://developer.github.com/v3/issues/#get-a-single-issue\"}"))

However, if I run the same command, but simply upgrade github package to 0.21, I get this output:

ParseError "Error in $: key \"updated_at\" not present"

So, my code is surely wrong, but the ParseError is misleading. I think we should be getting back an error tagged with the HTTPError data constructor.

I will keep looking, but let me know if you all have some thoughts.

@vrom911
Copy link
Member

vrom911 commented Mar 7, 2019

@StevenXL, I don't think that your code is wrong. It looks like that the new GitHub library is broken, and the error it returns looks very much like JSON parsing error, which means that they broke some encoders/decoders in the new release. I think we could try to create an issue there with the minimal example of this behaviour. Do you want to do this? 🙂

@StevenXL
Copy link
Author

@StevenXL, I don't think that your code is wrong. It looks like that the new GitHub library is broken, and the error it returns looks very much like JSON parsing error, which means that they broke some encoders/decoders in the new release. I think we could try to create an issue there with the minimal example of this behaviour. Do you want to do this? 🙂

Hello! I will try to provide a minimal, reproducible example on the github repository and then link to that here when I do.

@StevenXL
Copy link
Author

@vrom911 I couldn't write a small enough reproduction. (I was trying to use the script interpreter feature of stack but couldn't figure out how to get it to use github-0.21 given that v0.21 is not in any resolver).

This is a link to the issue in the github package.

@chshersh
Copy link
Contributor

@StevenXL I see that the issue is fixed (at least is says so) and github-0.22 is released. Can you try this with the newer github version?

@StevenXL
Copy link
Author

StevenXL commented Jun 26, 2019 via email

@StevenXL
Copy link
Author

StevenXL commented Jun 26, 2019 via email

@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from a42950d to b9dcffe Compare July 10, 2019 02:00
@StevenXL
Copy link
Author

StevenXL commented Jul 10, 2019

@chshersh Hi! I am trying to add github-0.22 to the project, but I am ending up in dependency hell (please excuse the phrasing). If you pull down this PR and run stack build, you will run into the following issue:

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for transformers-compat-0.6.5:
    transformers-0.5.6.2 from stack configuration does not match >=0.3 && ==0.2.*
needed due to hit-on-0.1.0.0 -> transformers-compat-0.6.5

I don't know how to proceed from here. Any help would be greatly appreciated.

@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from b9dcffe to cba73c3 Compare July 10, 2019 02:16
@chshersh
Copy link
Contributor

@StevenXL I can start building the project using the following stack.yaml file:

resolver: lts-13.27

extra-deps:
  - relude-0.5.0
  - shellmet-0.0.1

  - github-0.22
  - binary-orphans-1.0.1  # for github
  - binary-instances-1    # for github
  - time-compat-1.9.2.2   # for github

@StevenXL
Copy link
Author

@chshersh I was able to build with your suggestion. Thank you. Will continue to work on this.

@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from cba73c3 to ec6e2b9 Compare July 11, 2019 19:58
@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from ec6e2b9 to 77a0e80 Compare July 11, 2019 20:52
@StevenXL
Copy link
Author

@chshersh OK I think the functionality is finally working. Let me know your thoughts.

Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like progress 👍 And I have some suggestions

src/Hit/Issue.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
src/Hit/Cli.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
src/Hit/Git.hs Outdated Show resolved Hide resolved
src/Hit/Git.hs Outdated Show resolved Hide resolved
src/Hit/Git.hs Outdated Show resolved Hide resolved
Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I have one minor comment. Also, CI is failing because of HLint

src/Hit/Issue.hs Show resolved Hide resolved
Copy link
Member

@vrom911 vrom911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I have a couple of questions/suggestion

@@ -62,7 +62,7 @@ library

build-depends: base-noprelude ^>= 4.12.0.0
, ansi-terminal >= 0.8
, github ^>= 0.20
, github ^>= 0.22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should carefully check if this version broke something else again...

src/Hit/Cli.hs Show resolved Hide resolved
src/Hit/Cli.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
src/Hit/Issue.hs Outdated Show resolved Hide resolved
assignToIssue issue = withOwnerRepo assignAction >>= \case
Left err -> errorMessage (T.pack $ show err) >> exitFailure
Right AlreadyAssigned -> successMessage "Already assigned to issue"
Right NewlyAssigned -> successMessage "Assigned to issue"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the issue number and name in here (ideally the link as well, so the user could just click and go there).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great idea but would like that change to be an separate issue / pr.

@StevenXL StevenXL force-pushed the stevenxl/15-optionally-add-user-as-assignee branch from a2fe9f8 to 56e5200 Compare July 16, 2019 15:35
Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is okay. But I still see two problems with the implementation:

  1. The issue number is displayed in a wrong way under the hit issue command
 ➤   [#IssueNumber 81] Implement `hit diff` command with pretty diff
 ➤   [#IssueNumber 80] Add `hit uncommit` command
  1. I see the following error when trying to assign myself to an issue:
  HTTPError (HttpExceptionRequest Request {
  host                 = "api.github.com"
  port                 = 443
  secure               = True
  requestHeaders       = [("User-Agent","github.hs/0.21"),("Accept","application/vnd.github.v3+json"),("Authorization","<REDACTED>")]
  path                 = "/repos/kowainik/hit-on/issues/79"
  queryString          = ""
  method               = "PATCH"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 500, statusMessage = "Internal Server Error"}, responseVersion = HTTP/1.1, responseHeaders = [("Date","Wed, 17 Jul 2019 05:09:02 GMT"),("Content-Type","application/json; charset=utf-8"),("Content-Length","0"),("Server","GitHub.com"),("Status","500 Internal Server Error"),("X-RateLimit-Limit","5000"),("X-RateLimit-Remaining","4994"),("X-RateLimit-Reset","1563343672"),("X-OAuth-Scopes","read:discussion, read:gpg_key, read:org, read:public_key, read:repo_hook, repo, user"),("X-Accepted-OAuth-Scopes",""),("X-GitHub-Media-Type","github.v3; format=json"),("Access-Control-Expose-Headers","ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type"),("Access-Control-Allow-Origin","*"),("Strict-Transport-Security","max-age=31536000; includeSubdomains; preload"),("X-Frame-Options","deny"),("X-Content-Type-Options","nosniff"),("X-XSS-Protection","1; mode=block"),("Referrer-Policy","origin-when-cross-origin, strict-origin-when-cross-origin"),("Content-Security-Policy","default-src 'none'"),("X-GitHub-Request-Id","AFC4:2B04:1FE60A:29B1E1:5D2EAD6E")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) ""))

My initial guess would be that this is because I don't have enough permissions for my token. But I checked it at GitHub and as you can see in this response, the token has repo permission. So I don't know why this is happening 🤔 It would be nice to specify, what permissions from the token are required for this to work.

@piq9117
Copy link

piq9117 commented Aug 7, 2019

it sounds like y’all are experiencing the same problem with the github package as we did. We think it has something to do with the encoding where some fields are optional but the package puts in a Nothing which then becomes null instead of just leaving out that field. I’m guessing the request will succeed with curl or some other method like postman?

@chshersh
Copy link
Contributor

@piq9117 Parsing in github-0.21 was broken which stopped this PR from moving forward. The issue with parsing should be fixed in github-0.22 (as promised by CHANGELOG). I'm not sure what it's the problem now. This either might be wrong token scopes or something else. I agree with your proposed strategy for testing this: write curl command to test that the token is valid. And if curl command works, try to implement github version of it and open issue to the github library if it doesn't work.

@vrom911
Copy link
Member

vrom911 commented Sep 12, 2019

Hey @StevenXL, do you have plans for this PR?
Sorry for bothering!

@StevenXL
Copy link
Author

Hey @StevenXL, do you have plans for this PR?
Sorry for bothering!

@vrom911 It's no bother at all. I am going to close out the PR so if someone else wants to work on it, they don't feel the need to ask for "permission" or to check in on this PR.

Thank you for the reminder.

@StevenXL StevenXL closed this Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI command-line interface enhancement New feature or request GitHub GitHub API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When new branch for issue created add the user as assignee
4 participants