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

Pull-Request-Squash-Commit #1245

Merged
merged 9 commits into from
May 20, 2016
Merged

Pull-Request-Squash-Commit #1245

merged 9 commits into from
May 20, 2016

Conversation

Sarmad93
Copy link
Contributor

@Sarmad93 Sarmad93 commented Apr 5, 2016

Implementation of #1236 opened by @ryangribble for Preview Support for Pull Request Merge Api recently introduced by github.

@@ -225,7 +225,7 @@ public class TheMergeMethod
[Fact]
public void MergesPullRequest()
{
var mergePullRequest = new MergePullRequest { CommitMessage = "fake commit message" };
var mergePullRequest = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title" };
Copy link
Member

Choose a reason for hiding this comment

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

Is this a necessary change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No this is not necessary. but i thought i should also make changes in ObservablePullRequestsClientTests.cs .I wasn't sure that i should initialize property here or leave it as it was.. what do you say should i remove this?

Copy link
Member

Choose a reason for hiding this comment

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

It looks like we're not asserting anything about this object, so I think we should revert this change. 🆒?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes you are right..i should revert it now. 👍

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 5, 2016

oops look like i did some thing wrong and haven't pushed required changes

var merge = new MergePullRequest { CommitMessage = "fake message", CommitTitle = "fake title", Squash = true };
var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge);

Assert.True(result.Merged);
Copy link
Member

Choose a reason for hiding this comment

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

Could we assert something here about the commit title or message versus what we actually committed, to indicate this was squashed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure i will add assert statement here. 😃

Copy link
Member

Choose a reason for hiding this comment

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

One suggestion - look at the commit:

var commit = await _github.Repository.Commit.Get(_context.RepositoryOwner, _context.RepositoryName, result.Sha);
// TODO: something interesting goes here
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@shiftkey
Copy link
Member

shiftkey commented Apr 5, 2016

@Sarmad93 thanks for starting this off. I added a couple of comments to help us complete this feature and verify we're doing everything right...

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 5, 2016

@shiftkey thanks for guiding me. Sure we wil complete this one 👍

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 6, 2016

hi @shiftkey i am doing changes in integration test. when i ran build i saw that integration test were actually not running(skipping) because of some error

OCTOKIT_GITHUBUSERNAME and OCTOKIT_GITHUBPASSWORD environment variables are not set.

how can i make sure my test are passing? do i need to make a separate testing account for this?
thanks.

@ryangribble
Copy link
Contributor

how can i make sure my test are passing? do i need to make a separate testing account for this?
thanks.

@Sarmad93 yeah you should create a test account because the integration tests do things like create repos and other things. Generally they try to clean up after themselves where possible, but definitely you want a separate test account to do this under.

Refer to the integration test sectino in Contributors Guide for information about how to run the tests (essentially there's a powershell script to help you define those environment variables)

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 6, 2016

@ryangribble i will test these against testing account but i am pushing some changes could you please review these especially header functionality? i am not sure how this header parameter functionality works. i am stuck at this one need little help.

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 6, 2016

sorry for incomplete commits this smartgit github client really has some weird behavior 😠 doesn't always add all files to staging area.

@ryangribble
Copy link
Contributor

Im not in a position to pull your code down and run it myself just now, but eyeballing your changes, yes that looks correct in specifying the accept header on the ApiConnection.Put<T> call. The real test is whether your integration tests succeed, and the merged PR was squashed rather than merged!

However on the unit test mock verification you shouldnt use AcceptHeaders.xxxxx there (instead hardcode the expected header string) - we want the unit test to independently verify the implementation code, so we dont want to "share" that AcceptHeaders helper between implementation and tests (otherwise a bug/typo in the helper class will still pass the unit test!). Same way we manually check the Url that is called rather than use the ApiUrl helper method 😀

Regarding the integration test assertion, is there also a way to verify the commitTitle specified was correctly applied?

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 6, 2016

@ryangribble thanks for the code review 😆 yes i need to test these on testing account now.
Regarding AcceptHeaders.xxxxx in unit test, you explained very well i need to pass header as string in parameter 👍

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 8, 2016

i have configured my test account for integration test by running script in scripts\ configure-integration-tests.ps1 now i am getting some other errors from Octokit\GitHubClient.cs . i thinks my username and password is not updating from script. how can i resolve this?
capture11

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 8, 2016

i am stuck in this testing phase 😞

@shiftkey
Copy link
Member

shiftkey commented Apr 8, 2016

@Sarmad93 looking at those errors, I think something wasn't set correctly. You can run the same script again to view and update the values that the tests need.

@shiftkey shiftkey changed the title Pull-Request-Squash-Commit [WIP] Pull-Request-Squash-Commit Apr 14, 2016
@shiftkey
Copy link
Member

Just putting this back to WIP until we can confirm the integration test setup script is correct.

@ryangribble
Copy link
Contributor

Hey @Sarmad93, I'd definitely like to ensure these new GitHub features make it into the next octokit release so if time is an issue for you to get back onto this (totally understandable!) just let me know if you want someone to pick it up from here 😀

@Sarmad93
Copy link
Contributor Author

@ryangribble yes i have been busy for last days and last time i remember i was stuck on integration test setup and i wasn't sure where to add parameter(header) in post request so i stopped working on this 😫 got tired. you can assign this to someone else. Really sorry i could not made it.

@ryangribble
Copy link
Contributor

If you want to keep working on it you're more than welcome to!

It looks like you were at the point where we needed you to confirm your integration test settings... Easiest way is just to close visual studio, rerun the powershell script and ensure they are all set correctly, then have another go at running integration tests

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented Apr 19, 2016

@ryangribble i made a test account and set the script against testing account but after setting up the script i was getting these errors. why these test are failing? most of the test in PullRequestsClientTests.csare failing..they made me annoyed 😃 an exception is thrown from connection.cs file. something is not setting up or there is some thing wrong in response 😕
octokit2

@Sarmad93
Copy link
Contributor Author

@ryangribble also when i build project in visual studio 2015 i get this error also
octokit4

@shiftkey
Copy link
Member

@Sarmad93 some of the integration tests depend on the account being in a certain state - I've tried to keep it as runnable as possible for everyone, but differences do creep in which means they can fail.

If you want to focus on just your test, I'd suggest running it from in Visual Studio.

internal static class AssemblyVersionInformation
{
namespace System {
internal static class AssemblyVersionInformation {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unintended, right?

Copy link
Member

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 side-effect of .\build FormatCode - I'm tracking this in shiftkey/Octokit.CodeFormatter#2

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

unit tests + convention tests build is passing locally but not here? 😕

@devkhan
Copy link
Contributor

devkhan commented May 4, 2016

@Sarmad93 Your has conflicts with master, and that's why the CI builds are not running. Try to rebase your branch.

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

@devkhan still not building?

@devkhan
Copy link
Contributor

devkhan commented May 4, 2016

What did you do exactly?

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

@devkhan i did only this git rebase master and all that happened as you can see above :D

@devkhan
Copy link
Contributor

devkhan commented May 4, 2016

Did you updated you master from upstream first? You have to do that as that will fetch all the latest commits made in the main repo's master. Then you have to do the following to resolve conflicts:

git checkout <your_branch>
git rebase master
# Resolve any conflicts that may arise manually
# Then marked them resolved by:
git add .
# Then continue rebasing:
git rebase --continue
# Finally do a force push:
git push --force origin <your_branch>

Let me what happens after doing the above steps. 👍

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

@devkhan on step 4(git rebase --continue) i am getting this. 😕
capture00

@devkhan
Copy link
Contributor

devkhan commented May 4, 2016

And if there are any conflicts while cherry-picking, resolve them and commit too.

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

@devkhan sir first i would to thank you so much for your time and efforts 👍 i think this pr has gone to some fatal condition.. appveyor build is generating some strange errors 😆

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 4, 2016

@devkhan i have to redo this in a single commit. maybe it will solve the problem.

@devkhan
Copy link
Contributor

devkhan commented May 5, 2016

The reasons of those errors are the diffs which are inserted into the files on conflicts. I also think that a new PR may be better or if the conversation here is relevant, you can go actually delete your branch locally and then recreate it from the latest upstream master, and then re-do your work on top of it. And finally, do a force push.

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 17, 2016

i want to get back on this. i have free time for a while 😄 . I need a little help.
regarding passing the Header in put request i think i need to pass it in PullRequestClient.Merge . This merge method returns PullRequestMerge model object. In return statement the put method takes 4 input arguments. The one which confuses me the 3rd parameter string twoFactorAuthenticationCode Should i pass null here? or dummy text or i should update the position of parameters in overloaded put in IConnection class so that make Accept Header third input parameter and leave twoFactorAuthenticationCode without initializing it.

capture1

@shiftkey
Copy link
Member

@Sarmad93

The one which confuses me the 3rd parameter string twoFactorAuthenticationCode Should i pass null here?

You can specify null fine here.

or i should update the position of parameters in overloaded put in IConnection class so that make Accept Header third input parameter and leave twoFactorAuthenticationCode without initializing it.

Don't reorder the parameters as part of this PR. I'm not really sure why twoFactorAuthenticationCode is so pervasive in the IConnection signatures but let's avoid that for now...

@Sarmad93
Copy link
Contributor Author

@shiftkey could you please review changes i have made especially for Accept header?
Integration tests are not working for me. so i have tested it on creating new project and using access token. it works fine for me and squashes more than one commit into a single commit. kindly if you pull this code and run the integration test by yourself so that it could be verified that it is working as it intended to be 😄

@@ -184,6 +184,10 @@
<Project>{c8bc13b6-3fa3-4716-827d-e7706f976fe1}</Project>
<Name>Octokit-NetCore45</Name>
</ProjectReference>
<ProjectReference Include="..\Octokit\Octokit.csproj">
Copy link
Member

Choose a reason for hiding this comment

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

Not sure how this crept in, but this project reference shouldn't be needed 🔥 🔥 🔥

@Sarmad93
Copy link
Contributor Author

Sarmad93 commented May 19, 2016

@shiftkey Really sorry for that... i accidentally add all the files to staging area without observing closely...i will fix this and push new changes..sorry again if this made you angry..

@shiftkey
Copy link
Member

@Sarmad93 I'm not angry, I just like to delete code whenever possible 🔥

@shiftkey
Copy link
Member

@Sarmad93 I'm happy with that integration test - let's wrap this up and get it merged!

@Sarmad93
Copy link
Contributor Author

@shiftkey done.

@shiftkey shiftkey changed the title [WIP] Pull-Request-Squash-Commit Pull-Request-Squash-Commit May 20, 2016
@shiftkey
Copy link
Member

@Sarmad93 excellent, thanks!

@shiftkey shiftkey merged commit 3f39302 into octokit:master May 20, 2016
@shiftkey
Copy link
Member

@Sarmad93
Copy link
Contributor Author

@shiftkey @ryangribble as always thanks for your code review and guidance 👍 you guyz helped me to finish it to end.
@devkhan sir you taught me how to resolve merge/rebase conflict rightly,appreciate your efforts.

@devkhan
Copy link
Contributor

devkhan commented May 20, 2016

@Sarmad93 Glad I could help. You don't need to call me "Sir", we're all here to help each other. And I'm happy this PR is finally merged. Keep up the good work. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants