Open fyliu opened 2 months ago
Common things to look for in a PR review
peopledepot/main
_id
when going from DB to Django notationAbstractBaseModel
should not be addedIt already exists here https://github.com/hackforla/website/wiki/How-to-review-pull-requests
Django: How to combine migrations
Say max_migration.txt
is at 0027_...
and you want to combine 0025-0027 into one.
Roll back core
app migrations to 0024
./script/migrate.sh core 0024
Delete unwanted migration files
rm app/core/migrations/00{25,26,27}_*
Recreate max_migration.txt
for core
app
docker-compose exec web python manage.py create_max_migration_files --recreate core
# the file core/max_migration.txt should contain "0024_..."
Create combined migration file for core
app
./script/migrate.sh core
How to quickly checkout a PR
Setup: add this git alias to your global git config
[alias]
pr = !sh -c \"git fetch upstream pull/${1}/head:pr/${1} && git switch pr/${1}\"
Usage:
To check out PR #383 to a local branch called pr/383
, run this.
git pr 383
Notes:
upstream
.I have another longer alias for checking out a PR to a pr/xxxx
branch plus tracks the remote branch which created the PR. Here's the alias:
[alias]
prt = "!f() { \
git fetch upstream pull/${1}/head; \
commit_hash=$(git rev-parse FETCH_HEAD); \
remote_branch=$(git branch -r --contains $commit_hash | head -n 1); \
git switch -C prt/${1} $commit_hash; \
git branch -u $remote_branch prt/${1}; \
}; f"
Usage:
git prt 383
Note:
upstream
remote.prt/xxxx
branch if it already exists.git status -sb
to see tracking infoHow to add git alias to the global git config
Run this in the terminal to open an editor to to edit the global git config file.
git config --global -e
Add the git alias under the [alias]
section and save the file.
The alias is now available for use.
How to resolve migration conflict
Let's say you're rebasing and the max_migration.txt
file shows a conflict. That's a sign that the numbered migration files are conflicting as well. They're named differently so their conflicts don't show up in git.
In many cases, you can resolve it using the rebase_migration
command provided by django-linear-migrations
.
Let's say you rebase your branch to main
and see a conflict in core/migrations/max_migration.txt
git rebase upstream/main
For this example, let's say the conflict shows that core/0025
and core/0027
are in conflict.
Undo the rebase
You'd have migrations applied that are part of the conflict. You need to roll the database back to a point before that, so you can change those migrations if necessary.
git rebase --abort
Roll back the local database to a previous migration (any number before the ones in conflict)
./scripts/migrate.sh core 0024
Re-run the rebase
git rebase upstream/main
# see conflicts returned
Resolve the migration conflict
docker-compose exec web python manage.py rebase_migration core
Resolve any code conflicts
Run all the migrations
./scripts/migrate.sh core
Run pre-commit checks
pre-commit run —all-files
Stage all the fixes
git add <max_migration.txt> <changed migration files> <fixed code files>
Continue rebase
git rebase --continue
upstream/main
How to apply changes from one file to a different file
Say we have a branch that contains changes to CONTRIBUTING.md
and that the content being changed was moved to another file: docs/contributing/dev_environment.md
. We want to manually apply our change to the file ourselves.
Rebase/Merge your feature branch to main
Undo changes to CONTRIBUTING.md
git reset upstream/main -- CONTRIBUTING.md
git switch our-branch-original
git format-patch hackforla/main CONTRIBUTING.md
# only changes to CONTRIBUTING.md
# include changes since we branched off from hackforla/main
# may need to create a temporary branch where hackforla/main used to be for this command
# output:
# 0001-add-to-dev-environment.patch
CONTRIBUTING.md
changesgit switch our-branch-rebased
patch -p1 docs/contributing/dev_environment.md 0001-add-to-dev-environment.patch
git
cannot do it automatically unless the entire file was renamed.main
Please provide update
@shmonks Please provide update
@shmonks If you create a template with placeholders[REPLACE WITH...]
then you can get together with Vanessa, and show her how to create the issues using the template. Then she can write instructions for future documentation needs that come up.
This epic has now been replaced by the following issues:
Please provide update
Fang agreed that a new issue template for missing documentation would be good - so I'll proceed...
How to combine the last several commits into one.
This is not the only way but it's a fast way to achieve the goal.
git reset --soft Head~3
git commit --amend --no-edit
note: omit the --no-edit
flag if you want to edit the commit message.
There are alternative ways like lazygit
and the standard interactive rebase. These are more interactive and more difficult to write out in text form.
main
.upstream/main
, especially when there's also migration conflicts where more than one commit in the PR contain migration files. The repetitive resolving merge and migration conflicts can be simplified if the PR commits are all merged into one.Please provide update
- <!-- Where in mkdocs it should go. Provide url or indicate new page and parent page -->
The contributing docs should go inside the /docs/contributing/
folder or sub-folders
/docs/contributing/howto/
/docs/contributing/tutorial/
A guide for creating a new documentation page
I'm not sure if this falls under "style guides" or "howto"
create a front matters section at the top of the document like this:
---
tags:
- contributing-docs
- howto
- git
---
directory structure
├── docs
│ ├── contributing
│ │ ├── onboarding
│ │ ├── tutorials
│ │ ├── howto
│ │ ├── style
│ │ └── tools
│ ├── intro
│ ├── topics
│ ├── tutorials
│ ├── howto
│ └── API
where to put the page
graph LR
B -->|contributing| contributing;
B{contributing/client?} -->|client| client;
subgraph contributing [contributing docs]
direction LR
C -->|onboarding| F[/docs/contributing/onboarding/];
C -->|tutorial| D[/docs/contributing/tutorials/];
C -->|how to| E[/docs/contributing/howtos/];
C -->|style guide| G[/docs/contributing/style/];
C{content type} -->|tools| A[/docs/contributing/tools/];
end
subgraph client [client docs]
direction LR
H -->|introductory| I[/docs/intro/];
H -->|high level description| M[/docs/topics/];
H -->|tutorial| J[/docs/tutorials/];
H -->|howto| K[/docs/howto/];
H{content type} -->|API| L[/docs/api/];
end
Someone adding a new documentation page can reference this to make sure they're making use of all the available functionalities of the docs site and the documentation is like the rest of the documentation.
There's a comment asking where new docs pages should go. That's also included in this guide.
contributors, technical writers
howto, style guide, documentation
@fyliu Do you think the guide for creating a new documentation page be best in Wiki or Mkdocs?
@shmonks I was thinkin Mkdocs. Maybe it's helpful to keep it in the wiki until it's more stabilized?
Oh I see what you mean. This might be for non-developers as well. But this guide is for adding documentation to the Mkdocs site. So I'm thinking the writer will have Mkdocs running locally on their computer. But I guess the writer can also modify the text in GitHub's website and create the PR, which would automatically fix any syntax problems in the markdown, and then another writer can review and approve.
I think most of the howto guides actually needs someone with a developer background to go through them to make sure they produce the expected outcome.
What should be the process of working on an approving this type of work? Developer create the first draft and writer review and produce a final one?
Yes, I imagine we'd want a review - via PR probably best, then we could assign it to whoever. It sounds like Mkdocs would be the best place to have this new guide, with a link to it from the wiki.
Note: These steps work only for this project's database running locally in Docker container.
Get table definition
./scripts/db.sh -c "\d <table_name>"
Example table name: core_user
(Optional) Get all table names
./scripts/db.sh -c "\dt"
Enter the database shell in the docker container
./scripts/db.sh
Get list of tables
\dt
Get table definition
\d <table_name>
/docs/contributing/howto/generate-db-definition.md
-
. Standardizing so we don't have a mix of -
and *
bullets.1.
. The numbers will be autogenerated by the markdown renderer.Most of the contents are for the MkDocs site, so /docs/contributing/howto/format-markdown.md
But some contents are useful for GitHub as well, so also should add a link from the Wiki.
Overview
This issue tracks the documentation that needs to be added and the issue/pr where they would've been helpful in. The intention is to make it easy to note any missing documentation without having to create the issue at the same time.
Action Items
Resources/Instructions
How to use
Add a new comment for each documentation item needed using a copy of this template
Add an action item here, linking to the comment below
Create an issue to add the documentation (can be done later by another person)
Work on the documentation issue and check off the action item (can be done later by yet another person)