Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-06-07 21:10:00 +00:00
parent 21e144f387
commit c98df6ecba
25 changed files with 198 additions and 97 deletions

View file

@ -127,6 +127,7 @@ class ProfilesController < Profiles::ApplicationController
:include_private_contributions,
:timezone,
:job_title,
:pronouns,
status: [:emoji, :message, :availability]
)
end

View file

@ -312,6 +312,7 @@ class User < ApplicationRecord
delegate :other_role, :other_role=, to: :user_detail, allow_nil: true
delegate :bio, :bio=, :bio_html, to: :user_detail, allow_nil: true
delegate :webauthn_xid, :webauthn_xid=, to: :user_detail, allow_nil: true
delegate :pronouns, :pronouns=, to: :user_detail, allow_nil: true
accepts_nested_attributes_for :user_preference, update_only: true
accepts_nested_attributes_for :user_detail, update_only: true

View file

@ -6,6 +6,7 @@ class UserDetail < ApplicationRecord
belongs_to :user
validates :pronouns, length: { maximum: 50 }
validates :job_title, length: { maximum: 200 }
validates :bio, length: { maximum: 255 }, allow_blank: true

View file

@ -100,6 +100,7 @@
= render 'profiles/name', form: f, user: @user
= f.text_field :id, class: 'gl-form-input', readonly: true, label: s_('Profiles|User ID'), wrapper: { class: 'col-md-3' }
= f.text_field :pronouns, class: 'input-md gl-form-input', help: s_("Profiles|Enter your pronouns to let people know how to refer to you")
= render_if_exists 'profiles/email_settings', form: f
= f.text_field :skype, class: 'input-md gl-form-input', placeholder: s_("Profiles|username")
= f.text_field :linkedin, class: 'input-md gl-form-input', help: s_("Profiles|Your LinkedIn profile name from linkedin.com/in/profilename")

View file

@ -56,6 +56,9 @@
.user-info
.cover-title{ itemprop: 'name' }
= @user.name
- if @user.pronouns.present?
%span.gl-font-base.gl-text-gray-500.gl-vertical-align-middle
= "(#{@user.pronouns})"
- if @user&.status && user_status_set_to_busy?(@user.status)
%span.gl-font-base.gl-text-gray-500.gl-vertical-align-middle= s_("UserProfile|(Busy)")

View file

@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331006
milestone: '14.0'
type: development
group: group::release
default_enabled: false
default_enabled: true

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
class AddPronounsToUserDetails < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
# rubocop:disable Migration/AddLimitToTextColumns
# limit is added in 20210607050531_add_text_limit_to_user_details_pronouns
with_lock_retries do
add_column :user_details, :pronouns, :text, null: true
end
# rubocop:enable Migration/AddLimitToTextColumns
end
def down
with_lock_retries do
remove_column :user_details, :pronouns
end
end
end

View file

@ -0,0 +1,15 @@
# frozen_string_literal: true
class AddTextLimitToUserDetailsPronouns < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
add_text_limit :user_details, :pronouns, 50
end
def down
remove_text_limit :user_details, :pronouns
end
end

View file

@ -0,0 +1 @@
5b58dbdcba08f6e56802aa58ba0d23e5353c1818a8d4d653d53dabaac4c0234c

View file

@ -0,0 +1 @@
77f24cb4756dfeef16ba48a189d3bf9352534f858446522bc49495b9295374a8

View file

@ -18551,8 +18551,10 @@ CREATE TABLE user_details (
webauthn_xid text,
other_role text,
provisioned_by_group_id bigint,
pronouns text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100))
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)),
CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50))
);
CREATE SEQUENCE user_details_user_id_seq

View file

@ -9,7 +9,7 @@ type: howto
A branch is an independent line of development in a [project](../user/project/index.md).
When you create a new branch (in your [terminal](start-using-git.md#create-and-work-in-a-branch) or with
When you create a branch (in your [terminal](start-using-git.md#create-a-branch) or with
[the web interface](../user/project/repository/web_editor.md#create-a-new-branch)),
you are creating a snapshot of a certain branch, usually the main branch,
at its current state. From there, you can start to make your own changes without

View file

@ -311,35 +311,35 @@ git remote -v
The `-v` flag stands for verbose.
## Branching
## Branches
If you want to add code to a project but you're not sure if it works properly, or you're
collaborating on the project with others, and don't want your work to get mixed up, it's a good idea
to work on a different **branch**.
A **branch** is a copy of the files in the repository at the time you create the branch.
You can work in your branch without affecting other branches. When
you're ready to add your changes to the main codebase, you can merge your branch into
the default branch, for example, `main`.
When you create a branch in a Git repository, you make a copy of its files at the time of branching. You're free
to do whatever you want with the code in your branch without impacting the main branch or other branches. And when
you're ready to add your changes to the main codebase, you can merge your branch into the default branch
used in your project (such as `main`).
Use branches when you:
- Want to add code to a project but you're not sure if it works properly.
- Are collaborating on the project with others, and don't want your work to get mixed up.
A new branch is often called **feature branch** to differentiate from the
[default branch](../user/project/repository/branches/default.md).
### Create and work in a branch
### Create a branch
To create a new feature branch to work with:
To create a feature branch:
```shell
git checkout -b <name-of-branch>
```
Note that Git does **not** accept empty spaces and special characters in branch
names, so use only lowercase letters, numbers, hyphens (`-`), and underscores
(`_`). Do not use capital letters, as it may cause duplications.
Branch names cannot contain empty spaces and special characters. Use only lowercase letters, numbers,
hyphens (`-`), and underscores (`_`).
### Switch to a branch
You are always in a branch when working with Git.
All work in Git is done in a branch.
You can switch between branches to see the state of the files and work in that branch.
To switch to an existing branch:
@ -356,8 +356,8 @@ git checkout main
### View differences
To view the differences between your local, unstaged changes and the latest version
that you cloned or pulled, type:
To view the differences between your local unstaged changes and the latest version
that you cloned or pulled:
```shell
git diff
@ -365,9 +365,8 @@ git diff
### View the files that have changes
It's important to be aware of what's happening and the status of your changes. When
you add, change, or delete files or folders, Git knows about the changes.
To check which files have been changed use:
When you add, change, or delete files or folders, Git knows about the changes.
To check which files have been changed:
```shell
git status
@ -375,31 +374,35 @@ git status
### Add and commit local changes
Locally changed files are shown in red when you type `git status`. These changes may
be new, modified, or deleted files/folders. Use `git add` to **stage** (prepare)
a local file/folder for committing. Then use `git commit` to commit (save) the staged files.
When you type `git status`, locally changed files are shown in red. These changes may
be new, modified, or deleted files or folders.
```shell
git add <file-name OR folder-name>
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
```
1. To stage a file for commit:
To add more than one file or folder, repeat `git add` for each file or folder you want included
in the commit command before using `git commit`. Files that have been added show green when using `git status`.
```shell
git add <file-name OR folder-name>
```
#### Add all changes to commit
1. Repeat step 1 for each file or folder you want to add.
Or, to stage all files in the current directory and subdirectory, type `git add .`.
To add and commit (save) all local changes quickly:
1. Confirm that the files have been added to staging:
```shell
git add .
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
```
```shell
git status
```
NOTE:
The `.` character means _all file changes in the current directory and all subdirectories_.
The files should be displayed in green text.
To run `git add .` as part of the commit command, use the `-a` option:
1. To commit the staged files:
```shell
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
```
#### Stage and commit all changes
As a shortcut, you can add all local changes to staging and commit them with one command:
```shell
git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
@ -407,7 +410,7 @@ git commit -a -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
### Send changes to GitLab.com
To push all local commits (saved changes) to the remote repository:
To push all local changes to the remote repository:
```shell
git push <remote> <name-of-branch>
@ -419,27 +422,23 @@ For example, to push your local commits to the `main` branch of the `origin` rem
git push origin main
```
On certain occasions, Git disallows pushes to your repository, and then
Sometimes Git does not allow you to push to a repository. Instead,
you must [force an update](../topics/git/git_rebase.md#force-push).
NOTE:
To create a merge request from a fork to an upstream repository, see the
[forking workflow](../user/project/repository/forking_workflow.md).
### Delete all changes in the branch
To discard all changes of tracked files, type:
To discard all changes to tracked files:
```shell
git checkout .
```
Note that this removes *changes* to files, not the files themselves.
Any untracked (new) files are untouched.
This action removes *changes* to files, not the files themselves.
Untracked (new) files do not change.
### Unstage all changes that have been added to the staging area
To unstage (remove) all files that have not been committed from being committed, use:
To unstage (remove) all files that have not been committed:
```shell
git reset
@ -447,13 +446,13 @@ git reset
### Undo most recent commit
To undo the most recent commit, type:
To undo the most recent commit:
```shell
git reset HEAD~1
```
This leaves the changed files and folders unstaged in your local repository.
This action leaves the changed files and folders unstaged in your local repository.
WARNING:
A Git commit should not be reversed if you already pushed it
@ -465,16 +464,18 @@ You can learn more about the different ways Git can undo changes in the
### Merge a branch with default branch
When you are ready to make all the changes in a branch a permanent addition to
the default branch, you `merge` the two together, changing `<feature-branch>` and
`<default-branch>` to your values:
When you are ready to add your changes to
the default branch, you `merge` the two together:
```shell
git checkout <feature-branch>
git merge <default-branch>
```
In GitLab, you typically merge using a [merge request](../user/project/merge_requests/) instead of performing the command locally.
In GitLab, you typically use a [merge request](../user/project/merge_requests/) to merge your changes, instead of using the command line.
To create a merge request from a fork to an upstream repository, see the
[forking workflow](../user/project/repository/forking_workflow.md).
## Advanced use of Git through the command line
@ -482,14 +483,12 @@ For an introduction of more advanced Git techniques, see [Git rebase, force-push
## Synchronize changes in a forked repository with the upstream
[Forking a repository](../user/project/repository/forking_workflow.md) lets you create
a copy of a repository in your namespace. Changes made to your copy of the repository
are not synchronized automatically with the original.
Your local fork (copy) only contains changes you have made, so to keep the project
in sync with the original project, you need to `pull` from the original repository.
To create a copy of a repository in your namespace, you [fork it](../user/project/repository/forking_workflow.md).
Changes made to your copy of the repository are not automatically synchronized with the original.
To keep the project in sync with the original project, you need to `pull` from the original repository.
You must [create a link to the remote repository](#add-a-remote-repository) to pull
changes from the original repository. It is common to call this remote the `upstream`.
In this case, you [create a link to the remote repository](#add-a-remote-repository).
This remote is commonly called the `upstream`.
You can now use the `upstream` as a [`<remote>` to `pull` new updates](#download-the-latest-changes-in-the-project)
from the original repository, and use the `origin`

View file

@ -32,7 +32,7 @@ consider pulling it instead (`git pull origin master`). It has a similar
effect without compromising the work of your contributors.
It's safer to back up your branch before rebasing to make sure you don't lose
any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branching)
any changes. For example, consider a [feature branch](../../gitlab-basics/start-using-git.md#branches)
called `my-feature-branch`:
1. Open your feature branch in the terminal:

View file

@ -293,9 +293,9 @@ This output shows the repository history, including:
To undo changes in the remote repository, you can create a new commit with the changes you
want to undo. You should follow this process, which preserves the history and
provides a clear timeline and development structure. However, you only
need to follow this procedure if your work was merged into a branch that
other developers are using as the base for their work (for example, `main`).
provides a clear timeline and development structure. However, you
only need this procedure if your work was merged into a branch that
other developers use as the base for their work.
![Use revert to keep branch flowing](img/revert.png)
@ -310,7 +310,7 @@ git revert B
You can undo remote changes and change history.
Even with an updated history, old commits can still be
accessed by commit SHA, at least until all the automated cleanup
accessed by commit SHA. This is the case at least until all the automated cleanup
of detached commits is performed, or a cleanup is run manually. Even the cleanup might not remove old commits if there are still refs pointing to them.
![Modifying history causes problems on remote branch](img/rebase_reset.png)
@ -323,21 +323,21 @@ or a branch that might be used by other developers.
When you contribute to large open source repositories, like [GitLab](https://gitlab.com/gitlab-org/gitlab),
you can squash your commits into a single one.
A feature branch of a merge request is a public branch and might be used by
other developers, but project process and rules might allow or require
you to use `git rebase` (command that changes history) to reduce number of
displayed commits on target branch after reviews are done (for example
GitLab). There is a `git merge --squash` command which does exactly that
(squashes commits on feature-branch to a single commit on target branch
at merge).
To squash commits on a feature branch to a single commit on a target branch
at merge, use `git merge --squash`.
NOTE:
Never modify the commit history of your [default branch](../../../user/project/repository/branches/default.md) or shared branch.
### How to change history
You can modify history by using `git rebase -i`. This command allows modification, squashing, deletion
of commits.
A feature branch of a merge request is a public branch and might be used by
other developers. However, the project rules might require
you to use `git rebase` to reduce the number of
displayed commits on target branch after reviews are done.
You can modify history by using `git rebase -i`. Use this command to modify, squash,
and delete commits.
```shell
#
@ -360,41 +360,40 @@ of commits.
```
NOTE:
If you decide to abort, do not close your editor, because the history
will change. Instead, remove all uncommented lines and save.
If you decide to stop a rebase, do not close your editor.
Instead, remove all uncommented lines and save.
Use `git rebase` carefully on
shared and remote branches, but rest assured: nothing is broken until
you push back to the remote repository (so you can freely explore the
different outcomes locally).
Use `git rebase` carefully on shared and remote branches.
Experiment locally before you push to the remote repository.
```shell
# Modify history from commit-id to HEAD (current commit)
git rebase -i commit-id
```
### Deleting sensitive information from commits
### Delete sensitive information from commits
Git also enables you to delete sensitive information from your past commits and
it does modify history in the progress. That is why we have included it in this
section and not as a standalone topic. To do so, you should run the
`git filter-branch`, which enables you to rewrite history with
[certain filters](https://git-scm.com/docs/git-filter-branch#_options).
This command uses rebase to modify history and if you want to remove certain
file from history altogether use:
You can use Git to delete sensitive information from your past commits. However,
history is modified in the process.
To rewrite history with
[certain filters](https://git-scm.com/docs/git-filter-branch#_options),
run `git filter-branch`.
To remove a file from the history altogether use:
```shell
git filter-branch --tree-filter 'rm filename' HEAD
```
Because `git filter-branch` command might be slow on big repositories, there are
tools that can use some of Git specifics to enable faster execution of common
tasks (which is exactly what removing sensitive information file is about).
The `git filter-branch` command might be slow on large repositories.
Tools are available to execute Git commands more quickly.
An alternative is the open source community-maintained tool [BFG](https://rtyley.github.io/bfg-repo-cleaner/).
Keep in mind that these tools are faster because they do not provide the same
These tools are faster because they do not provide the same
feature set as `git filter-branch` does, but focus on specific use cases.
Refer [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) page to know more about purging files from repository history & GitLab storage.
Refer to [Reduce repository size](../../../user/project/repository/reducing_the_repo_size_using_git.md) to
learn more about purging files from repository history and GitLab storage.
<!-- ## Troubleshooting

View file

@ -107,6 +107,20 @@ To show private contributions:
1. In the **Main settings** section, select the **Include private contributions on my profile** checkbox.
1. Select **Update profile settings**.
## Add your gender pronouns
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332405) in GitLab 14.0.
You can add your gender pronouns to your GitLab account to be displayed next to
your name in your profile.
To specify your pronouns:
1. In the top-right corner, select your avatar.
1. Select **Edit profile**.
1. In the **Pronouns** field, enter your pronouns.
1. Select **Update profile settings**.
## Set your current status
> - Introduced in GitLab 11.2.

View file

@ -112,6 +112,10 @@ contact the SubGit team directly at [support@subgit.com](mailto:support@subgit.c
## Cut over migration with svn2git
NOTE:
Any issues with svn2git should be directed to the [relevant project and maintainer](https://github.com/nirvdrum/svn2git).
Check for existing issues and history for update frequency.
If you are currently using an SVN repository, you can migrate the repository
to Git and GitLab. We recommend a hard cut over - run the migration command once
and then have all developers start using the new GitLab repository immediately.

View file

@ -33,7 +33,7 @@ For more information on managing branches using the GitLab UI, see:
- [Branch filter search box](#branch-filter-search-box)
You can also manage branches using the
[command line](../../../../gitlab-basics/start-using-git.md#create-and-work-in-a-branch).
[command line](../../../../gitlab-basics/start-using-git.md#create-a-branch).
<i class="fa fa-youtube-play youtube" aria-hidden="true"></i>Watch the video [GitLab Flow](https://www.youtube.com/watch?v=InKNIvky2KE).

View file

@ -1,5 +1,8 @@
# frozen_string_literal: true
# This patch will be included in the next Rails release: https://github.com/rails/rails/pull/42368
raise 'This patch can be removed' if Rails::VERSION::MAJOR > 6
# rubocop:disable Gitlab/ModuleWithInstanceVariables
module Gitlab
module Database

View file

@ -25244,6 +25244,9 @@ msgstr ""
msgid "Profiles|Enter your name, so people you know can recognize you"
msgstr ""
msgid "Profiles|Enter your pronouns to let people know how to refer to you"
msgstr ""
msgid "Profiles|Expired key is not valid."
msgstr ""

View file

@ -100,6 +100,16 @@ RSpec.describe ProfilesController, :request_store do
expect(user.reload.job_title).to eq(title)
expect(response).to have_gitlab_http_status(:found)
end
it 'allows updating user specified pronouns', :aggregate_failures do
pronouns = 'they/them'
sign_in(user)
put :update, params: { user: { pronouns: pronouns } }
expect(user.reload.pronouns).to eq(pronouns)
expect(response).to have_gitlab_http_status(:found)
end
end
describe 'GET audit_log' do

View file

@ -4,5 +4,6 @@ FactoryBot.define do
factory :user_detail do
user
job_title { 'VP of Sales' }
pronouns { nil }
end
end

View file

@ -220,6 +220,14 @@ RSpec.describe 'User page' do
expect(page).to have_content("Working hard!")
end
it 'shows the pronouns of the user if there was one' do
user.user_detail.update_column(:pronouns, 'they/them')
subject
expect(page).to have_content("(they/them)")
end
context 'signup disabled' do
it 'shows the sign in link' do
stub_application_setting(signup_enabled: false)

View file

@ -11,6 +11,11 @@ RSpec.describe UserDetail do
it { is_expected.to validate_length_of(:job_title).is_at_most(200) }
end
describe '#pronouns' do
it { is_expected.not_to validate_presence_of(:pronouns) }
it { is_expected.to validate_length_of(:pronouns).is_at_most(50) }
end
describe '#bio' do
it { is_expected.to validate_length_of(:bio).is_at_most(255) }
end

View file

@ -74,6 +74,9 @@ RSpec.describe User do
it { is_expected.to delegate_method(:job_title).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:job_title=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:pronouns).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:pronouns=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:bio).to(:user_detail).allow_nil }
it { is_expected.to delegate_method(:bio=).to(:user_detail).with_arguments(:args).allow_nil }
it { is_expected.to delegate_method(:bio_html).to(:user_detail).allow_nil }
@ -136,6 +139,12 @@ RSpec.describe User do
expect(user.bio).to eq(user.user_detail.bio)
end
it 'delegates `pronouns` to `user_detail`' do
user = create(:user, pronouns: 'they/them')
expect(user.pronouns).to eq(user.user_detail.pronouns)
end
it 'creates `user_detail` when `bio` is first updated' do
user = create(:user)