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

Tw2 #268

Closed
wants to merge 5 commits into from
Closed

Tw2 #268

wants to merge 5 commits into from

Conversation

vovan-zt
Copy link
Contributor

OOP exercise

Demo |
Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review. repeated requested

@OleksiyRudenko
Copy link
Member

OleksiyRudenko commented Aug 23, 2022

Good PR, just like a good function or a good commit, does only one job. E.g. adds a new feature OR fixes mistakes.
There was a reason why last correction we did actually worked.
Take a learning from that case and project it on your future experiences. Be thoughtful.
image

Also I'd assume your fork's main has diverged from upstream/main significantly and you risk having your future submissions polluted with irrelevant and unneeded commits.

image

My recommendation is to fix this now, for us (I mean you and reviewers) save some time and avoid stepping on the same rake.

Check materials under item 2 in Contributions Troubleshooting section.

Follow the guidelines and ask specific questions, here or in Students' chat.

@vovan-zt
Copy link
Contributor Author

B2. Коли потрібні будь-які зміни
Щоразу, коли ви хочете або вам буде запропоновано внести будь-які зміни, виконайте такі дії:

B21. Оновіть свою програму (у відповідному app repo):

впровадити зміни
переконайтеся, що публікація вашої програми оновлена
B22. Оновіть свій PR - у вашому homeworks local repo:

git checkout
скопіюйте змінені файли (один за одним) у ваш каталог завдань із app repo
stage, commit і push
Ваш PR буде оновлено автоматично.

B23. Перевірте свій PR і повідомте ментора:

перейдіть до свого PR у homeworks main repo
перевірте надіслані файли в розділі Файли змінено; ви повинні побачити свої останні зміни у файлах
клацніть Re-request review у списку ваших PR-рев'юерів щоб привернути увагу наставників, щоб вони знали, що є нові зміни для перегляду
Коли ваш PR буде нарешті змержено, напишіть міркування про завдання і досвід код рев'ю до вашого щоденника студента (ваш repo kottans-frontend):

що для вас було нового
що вас здивувало
що ви збираєтеся використовувати в майбутньому

I already figured it out for myself.
I will do the same in other projects.

Before each created project, I ran the command.

git checkout main
git pull upstream main
git push origin main

Was it my fault?

@OleksiyRudenko
Copy link
Member

If it was a commercial project this PR would be probably denied altogether.
It adds a required feature. It also introduces changes to unrelated parts of the project.
Encapsulation and cleanliness of PRs and commits is no less important that encapsulation and cleanliness of code.
Please make this PR contain only what is required by the task and contribution guidelines.

@OleksiyRudenko
Copy link
Member

@vovan-zt

Brief analysis:
image

This means that your fork's main contains commits that are not on the upstream repo's main.

This happens when something is committed to the fork's main branch directly rather than via branch-commit-push-PR-merge workflow or when merging of feature branch with main was done with wrong branches order (checkout feature-branch && merge main is not the same as checkout main && merge feature-branch). Fork's main branch should be updated from upstream's main branch only.

These "foreign" commits make main branch histories diverge and that's why extra merge commits required/appear on the fork's branch, making history diverge even further with every git pull upstream.

Follow ... commits ahead link to see the difference between fork and upstream
image

This history difference will cause more troubles.

There are two options as to how to resolve the issue:

  1. Re-sync fork's and upstream's main branches (guidelines are available under item 2 in Contributions Troubleshooting section). Not an easy approach but you will learn something new, gain a new skill and hopefully will understand git better.
  2. Kill the fork and local repo, re-fork again. But any currently open PRs will get automatically closed as the fork won't exist anymore. You will need to re-submit code and catch up to the ongoing reviews somehow.

Let me know if you want to follow option 1. It is doable and less disruptive. We can complete it making baby steps.

The 2nd option seems simpler but will require no less efforts altogether.

@OleksiyRudenko OleksiyRudenko added the irrelevant-commits Commits not related to current task label Aug 25, 2022
@github-actions
Copy link

github-actions bot commented Aug 25, 2022

discarded

@OleksiyRudenko
Copy link
Member

Added label to find the PR faster using PR filters.

@vovan-zt
Copy link
Contributor Author

vovan-zt commented Aug 25, 2022

I can always crush my fork. First I need to try option #1

I'll read it in the evening, if I figure it out, I'll try.

@OleksiyRudenko
Copy link
Member

That's a proper attitude.

When you read the materials, please share your findings on your repo and suggest an action plan. We shall review it, adjust if needed and implement.

@vovan-zt
Copy link
Contributor Author

git branch backup-feature
git checkout master
git branch backup-master

git checkout 676172e
git branch -f master
git checkout master
git push -f

git remote add upstream https://github.com/kottans/frontend-2022-homeworks.git
git pull upstream master
git push origin main

git branch -f feature-branch
git checkout feature-branch
make some changes
git cherry-pick 676172e
git push -f

git branch -d backup-feature
git push origin --delete backup-feature

git branch -d backup-master
git push origin --delete backup-master

@OleksiyRudenko
Copy link
Member

General, this repo's main branch is main not master

Block 2:

git checkout https://github.com/kottans/frontend-2022-homeworks/commit/676172ed7f1f177ac439b04b2c4c4acdb07184f6
git branch -f master
git checkout master
git push -f

Does 676172e belong to upstream's master?
If not then we will still have a problem, just smaller. We need to have main branch pointer on fork point at the latest commit on upstream's main branch that exists both on upstream and fork.

Block 3:

git remote add upstream https://github.com/kottans/frontend-2022-homeworks.git

We should have this already set up. Although no harm in re-assigning upstream once again.

Block 4:

git branch -f feature-branch
git checkout feature-branch
make some changes
git cherry-pick https://github.com/kottans/frontend-2022-homeworks/commit/676172ed7f1f177ac439b04b2c4c4acdb07184f6
git push -f

Is this exactly the commit you want to keep? Why?
If there is a good reason, we still need to "save" other commits on this PR.

Also replace feature-branch with actual branch name you want to have.

@vovan-zt
Copy link
Contributor Author

I accidentally deleted 4 commits ahead via github

@vovan-zt
Copy link
Contributor Author

Will this somehow help my problem or am I making it worse?

@vovan-zt
Copy link
Contributor Author

Maybe it makes sense to delete this branch and create a new one?
Since I'm already a little confused

@OleksiyRudenko
Copy link
Member

Probably, it will be easier to re-do this PR from the scratch

@vovan-zt vovan-zt closed this Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
irrelevant-commits Commits not related to current task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants