Gerrit/Tutorial/tr

Bu, Git ve Gerrit'in Wikimedia gelişimi için nasıl kullanılacağını açıklayan bir öğreticidir.


 * Zaman kazanmak ve teknoloji meraklısıysanız, bunun yerine çok kısa nasıl yapılır kılavuzunu kullanın:
 * Uzman kullanıcılar için ek belgelere sahiptir.
 * Yalnızca Gerrit ile oynamak ve "gerçek" bir Wikimedia yazılım projesi için bir yama yazmak istemiyorsanız, bunun yerine Gerrit test örneğimizi kullanın.

Bu öğreticide, kutudaki dolar işareti ile başlamak için aşağıdaki gibi komutlar:. önekini girmeyin. Komut ayrıca kendinizi değiştirmeniz gereken bir değişken de içeriyorsa, değişken kırmızı renkte gösterilir:.

Git nedir?
Git ücretsiz ve açık bir kaynaktır dağıtılmış sürüm kontrol sistemi. “Dağıtılmış”, deponun merkezi bir kopyası olmadığı anlamına gelir. Git ile, depoyu klonladıktan sonra, tüm dallar ve etiketli sürümler elinizin altında olacak şekilde kaynak kodunun tam olarak çalışan bir kopyasına sahip olursunuz.

Gerrit nedir?
Gerrit Git ile entegre olan ücretsiz, web tabanlı bir ortak kod inceleme aracıdır.

Temel olarak: Önerilen yazılım değişikliğinizi (Gerrit'te "changeset" olarak adlandırılır) yeni bir dal olarak gönderirsiniz. İlk sürüm ("patchset 1") henüz mükemmel değilse, o dalda ("patchset 2" vb.) daha fazla değişiklik yapabilirsiniz ("amend"). Bir yama seti bir "+2" incelemesi aldığında, kabul edilir ve kod deposunun ana dalında birleştirilir (genellikle "master" olarak adlandırılır). Birleştirme, birisi bu kod deposunu teslim aldığında veya indirdiğinde, yaptığınız değişikliğin varsayılan olarak dahil edileceği anlamına gelir.

Wikimedia geliştirici hesabı oluşturun
Henüz bir Wikimedia geliştirici hesabınız yoksa, wikitech.wikimedia.org sayfasına gidin ve bir hesap oluşturun. Aynı kullanıcı adı ve parola aşağıdaki Gerrit'te oturum açmak için kullanılacaktır.

Git'i kurun
Bu talimatlar Git'in komut satırı (terminal penceresi) aracı olarak nasıl kurulacağını açıklar. Komut satırı yerine grafik kullanıcı arabirimi (GUI) tercih ederseniz, Git projesi tarafından tutulan istemcilerin listesini denetleyin. Alternatif kurulum talimatları için resmi belgelere bakın.

Font Awesome 5 brands linux.svg Linux

 * paketini kurmak için Linux dağıtımınızın grafiksel yazılım paketi yönetim aracını kullanın.
 * Git dağıtımınız tarafından paketlenmemişse, lütfen dağıtımınızın destek forumuna sorun.

Font Awesome 5 brands windows.svg Windows

 * Windows için Git ile https://gitforwindows.org/ üzerinden yükleyin. Bu size Git'e ek olarak bu talimatlardaki komut satırlarının çoğunun Windows üzerinde çalışmasına izin veren "Git Bash" adlı bir kabuk verir.

Apple logo black.svg macOS

 * Homebrew paket yöneticisini kurun ve sonra komutunu çalıştırın – Diğer paketlerin kolay güncellenmesine ve kolayca kurulmasına izin verdiği için bu önerilir.
 * Alternatif olarak, tek başına Git for Mac yükleyebilirsiniz.

Git'i yapılandırın
Git'i yüklediğinize göre artık kişisel bilgilerinizi yapılandırma zamanı. Bunu sadece bir kez yapmanız gerekir. Ayrıca bu komutları tekrar çalıştırarak kişisel bilgilerinizi istediğiniz zaman değiştirebilirsiniz.

Git, kullanıcının adını ve e-postasını kontrol ederek her işlemi yapanları izler. Ayrıca, bu bilgi taahhütlerinizi Gerrit hesabınızla ilişkilendirmek için kullanılır.

Kullanıcı adınızı ve e-posta adresinizi ayarlamak için aşağıdaki iki komutu girin. ile kendi Gerrit kullanıcı adınızla değiştirin ve ile kendi e-posta adresinizle değiştirin:

Gerrit'te SSH Anahtarlarını Ayarla
Bilgisayarınız ve Gerrit arasında güvenli bir bağlantı kurmak için bir SSH anahtarı kullanıyoruz. Yepyeni bir anahtar oluşturmanız gerekip gerekmediğinden emin olmak için, sisteminizde zaten bir SSH anahtarı olup olmadığını kontrol edelim. Bu komutu bir terminalde çalıştırın:

Komut, (gizli)  dizinindeki dosyaları listeler. Dizin sisteminizde zaten varsa ve çıkışta  adlı bir dosya listeleniyorsa, doğrudan #SHH Genel anahtarınızı kopyalayın bölümüne gidebilirsiniz.

Yeni bir SSH anahtarı oluşturun
Yeni bir SSH anahtarı oluşturmak için aşağıdaki komutu girin ve yerine kendi e-posta adresinizi yazın. Varsayılan ayarları istiyoruz, bu nedenle anahtarı kaydetmek için bir dosya girmeniz istendiğinde, enter tuşuna basın.

Güçlü ve benzersiz bir parola girin ve [Enter] tuşuna basın.


 * Why do passphrases matter?
 * Passwords aren’t very secure. If you use one that’s easy to remember, it’s easier to guess or brute-force. If you use one that’s random it’s hard to remember, so you might write the password down. Both are very bad. This is why you’re using ssh keys. But using an ssh key without a passphrase is basically the same as writing down that random password in a file on your computer. Anyone who gains access to your drive has gained access to every system you use that key with. That's why you also add a passphrase. To not enter a long passphrase every time you use the key, there’s a tool called . It can save your passphrase securely. If you use macOS or Linux, then your keys can be saved in the system’s keychain to make your life even easier.

The  command will create 2 files in   directory:


 * : your private SSH key (for identification)
 * : your public SSH key

SSH Genel anahtarınızı kopyalayın
Genel anahtar dosyanızın içeriğini (örneğin, ) panonuza kopyalayın:

Bir seçenek, ortak anahtar dosyanızı en sevdiğiniz metin düzenleyicisiyle (Notepad, TextEdit, gedit vb.) açmaktır. Metin düzenleyicinizin dosya seçici iletişim kutusunda, dosyayı bulmak için “Gizli dosyaları görüntüle”'yi açmanız gerekebilir, çünkü  dizini gizlidir. Bazen "Gizli dosyaları görüntüle" seçeneği, dosya seçici iletişim kutusuna sağ tıklayarak kullanılabilir.

Diğer seçenekler:


 * On Linux, run and manually copy the output to the clipboard.
 * On Windows, you can open Git GUI, go to Help 🡒 Show Key, and then press "Copy To Clipboard" to copy your public key to your clipboard.
 * On macOS, you can run to copy the contents of the your public key file to your clipboard.

It’s important you copy your SSH Public key exactly as it is written, without adding any newlines or whitespace. Copy the full text, including the "ssh-rsa" prefix, the key itself, and the email address suffix.

Gerrit hesabınıza SSH Genel anahtarı ekleyin

 * Log into the web interface for Gerrit. The username and password for your Gerrit are the same as for your Wikimedia Developer account.
 * Click on your username in the top right corner, then choose "Settings".
 * Click "SSH Public Keys" in the menu on the left.
 * Paste your SSH Public Key into the corresponding field and click "Add".

Git ile kullanmak için SSH Özel anahtarı ekleyin
Git Bash komut satırını başlatın.


 * Get ssh-agent running using
 * Be sure to use the accent, not the single quote  . (You could copy and paste from this page if you cannot easily enter this special character.)
 * Be sure to use the accent, not the single quote  . (You could copy and paste from this page if you cannot easily enter this special character.)


 * Add your private key to the agent. If you followed the steps above and your key has the default name, then the command is:


 * Connect to the Gerrit server via  to check if everything works as expected. Replace  by your username as shown in your Gerrit settings:


 * Be paranoid and compare that the "RSA key fingerprint" is the same as the SSH fingerprint for gerrit.wikimedia.org:29418. If it is the same, answer "Yes" to "Are you sure you want to continue connecting?". Then enter the passphrase for your key.
 * You should get a message "Welcome to Gerrit Code Review". The last line should show "Connection to gerrit.wikimedia.org closed."
 * If you run into problems, use (replace  by your username). The   will provide verbose output to help find problems. Then read Gerrit/Troubleshooting.

An example Gerrit SSH connection success message looks like this:

Git'i kullanarak kod indirin
"Sandbox" adlı deposu indirerek ("cloning" denir) pratik yapalım. Git Bash komut satırı üzerinde aşağıdakileri çalıştırın:

(Replace by your Gerrit username. And make sure the URL begins with   and not  ).

Bu işlem, "sandbox" uzantı deposunun tüm geçmişini ve kod tabanını makinenize kopyalar. Uzantının ana dalının (genellikle "git master" olarak da bilinir) bir çalışma dizinine sahip olursunuz. Yeni dizini girin ( komutu ile). Artık koda bakıp düzenlemeye başlayabilirsiniz.

Gerrit ile çalışmaya hazırlanın
Gerrit requires that your commit message must have a "change ID". They look like  starting with an I (capital i). Each time you amend a commit to improve an existing patch in Gerrit, this change ID stays the same, so Gerrit understands it as a new "patch set" to address the same code change.

There's a git add-on called git-review that adds a Change-ID line to your commits. Using git-review is recommended. It makes it easier to configure your Git clone, to submit a change or to fetch an existing one.

git-review yükleme
Daha fazla bilgi için lütfen Gerrit/git-review|#Kurulum bölümüne bakın.

Font Awesome 5 brands linux.svg Linux

 * Use the graphical software package management tool of your Linux distribution to install the  package.
 * If git-review has not been packaged by your distribution, check Gerrit/git-review for other options such as installing git-review by using the pip Python package installer.
 * If you use FreeBSD, install git-review through ports.

Font Awesome 5 brands windows.svg Windows

 * Please see Gerrit/git-review.

Apple logo black.svg macOS

 * For OS X 10.11 El Capitan and later, follow Gerrit/git-review.
 * On versions prior to 10.11, use the pip Python package installer by following Gerrit/git-review.

git-review yapılandırma
Git'in varsayılan uzak ana bilgisayar adı "origin". Bu ad Wikimedia projeleri tarafından da kullanılır. Bu konağı kullanabilmek için git-review söylememiz gerekiyor. yerine Gerrit kullanıcı adınızı yazın:

git-review ayarlama
Bir depoyu indirdikten ("cloning") sonra, git-review için ayarlamanız gerekir. Bu, bir taahhüdü ilk kez göndermeye çalıştığınızda otomatik olarak gerçekleşir, ancak bunu klonlamadan hemen sonra yapmak genellikle daha iyidir. Klonladığınız projenin dizininde olduğunuzdan emin olun (aksi takdirde "hata: Git deposu değil" hatası alırsınız). Ardından şu komutu çalıştırın:

Çıkışının sonuna doğru, şöyle bir şey görmelisiniz:

Bu, kullandığınız kabuk kullanıcı adından farklıysa git kullanıcı adınızı isteyebilir.

Bir yama gönderin
Make sure that you cloned the code repository that you are interested in (see ).

Make sure that you are in the directory of the code repository (the command tells you where exactly you are).

Güncelleme yöneticisi
Make sure that your master branch (the branch created when you initially cloned the repository) is up to date:

However, note that a few repositories use different terms (for example, the  repository has a   instead of a   branch).

Bir dal oluştur
First, create a local branch for your new change. Replace below by a short but reasonably descriptive name (e.g.   if a corresponding Phabricator task exists for your changes, , or  ). Other people will also use this name to identify your branch.

This will create a new branch (called ) from the latest 'master' and check it out for you. In the example above, we called that new branch.

Değişikliklerinizi yapın
Make changes to your local code. Use your preferred text editor and modify a file. In the example below, we edit the file  and add a word.

Then close your text editor and check the changes you have made since the last commit, within the file(s) and within the directory:

displays your changes in unified diff format: Removed lines have a minus prefix and added lines have a plus  prefix. These changes are not yet "staged" (via ) for the next commit.

Stage your changes for a commit
Run to decide which of your changes should become part of your commit. It will display a list of all file(s) that you have changed within the directory. At this point, the output will display "no changes added to commit" as the last line.

Use  to make your changed file(s) become part of your next commit. In the example above we modified the file, so the command would be:

Any files you've changed that you have not passed to  will be ignored when running   in the next step.

Commit your staged changes
Once you are happy with the list of changes added via, you can turn these changes into a commit in your local repository by using

You will then be asked in your text editor to add a descriptive summary for your commit. You must follow the Commit message guidelines. This is what other people will see when looking at the history of changes in the code repository.

Save the commit message and close your text editor. A summary (the commit ID, your subject line, the files and lines changed) will be displayed.

Prepare to push your commit to Gerrit
Synchronize your changeset with any changes that may have occurred in the master branch while you've been working ("rebasing"). From within your branch, run:

Now you are ready to push your code to Gerrit for review. If you made several related commits, consider merging them into one single commit for review.

Push your commit to Gerrit
If you followed above and installed   and ran , then the command to push changes to Gerrit is:

The  option tells git-review not to perform a rebase before submitting the change to Gerrit.

Upon success, you'll get a confirmation and a link to the changeset in Gerrit. In the example above, that link is: https://gerrit.wikimedia.org/r/#/c/sandbox/+/563720

Congratulations! Your patch is in Gerrit and hopefully will get reviewed soon!

View the Change / Next Steps
If you open the link to your Gerrit changeset in a web browser, you can see your changed files in their context when you click on the  link in the "Commit" line.

If your commit addresses a ticket in Phabricator, a comment will be automatically added in the Phabricator task if you followed the Commit message guidelines. If you did not, you could manually add a comment on that Phabricator ticket by linking to its changeset in Gerrit.

Other common situations
Also see Gerrit/Advanced usage if your situation is not covered here.

Squash several commits into one single commit via rebase
If you made several related commits to your local repository prior to wanting to submit for review, you should squash (merge) those commits into one single commit.

The  or   option allows you to change (rewrite) your commit history. For each commit, you can modify and change the commit message, add or remove files, or perform other modifications.

First you need to tell git how far back you want to pull. To get a list of all changes in your branch:

You can also limit the displayed list of recent changes. means pull the last three commits:

After you type this command, your text editor will display your commits in reverse order and a list of available commands:

Since we only want to send one commit to review, we will squash the last two commits into the first. Hence change all but the first "pick" to "squash":

pick aa8cf1d Adding method customFilterFunctionGetRiskyCountryCodeScore to GatewayAdapter. squash 38828e2 Adding $wgDonationInterfaceCustomFiltersFunctionsRiskyCountries to donationinterface.php squash be33007 Fix a typo

When you finished picking and squashing and saved the file, another file will open in your text editor to allow you get to edit and merge your commit messages. Be careful to only keep one of the Change-Id lines and have it be at bottom of the message after one empty line.

Your messages from your previous commits will automatically be placed in this message:

Remember to put your (updated) summary message in the commit. In this case the new summary message will be:

(mingle-fr-2012-69) Adding a custom filter for risky countries.

If all goes well, you should see a successful rebase message:

Afterwards, submit your patch for review:

You should see a message like this showing your git review went to Gerrit (in this example, to https://gerrit.wikimedia.org/r/7187):

Amending a change (your own or someone else's)
Sometimes, you might need to amend a submitted change. You can amend a change as long as the change hasn't been merged yet.

You can amend your own changes. To amend changes submitted by someone else, you need to be a member of Gerrit's Trusted-Contributors group. To become a member of Trusted-Contributors, find someone who is a member and ask them to add you. The group is viral in that members can add new members, use your powers responsibly.

Rebase to bring your local branch up to date with the remote. It's best to make rebase updates a separate patch, so that your code reviewers have an easy time seeing what changes you've made. Assuming you are using Gerrit, you can do this by clicking the "Rebase Change" button when viewing your patch in Gerrit's web interface.

Hard reset and checkout the change with this command: (BEWARE:  performs a hard reset that destroys all local changes. Stash or commit changes first which you wish to preserve!)

For example:

Note, if you already have the change in a branch on your local repository, you can just check it out instead:

For example:

Next, make some changes with your favorite text editor.

the files as needed, then commit the change (ensuring you are amending the commit):

Push the change:

The  is important here. It tells git-review to not rebase your change against master, which clutters diffs between patch set 1 and 2.

Push to a branch different than master
Above, the commit was pushed to the master branch. The branch name only appeared as the topic of the commit in the Gerrit UI. If you really want to push to a different branch than master, you have to push via.

Editing via the web-interface
If you're logged in to Gerrit, you can also create code changes directly within the web interface. This can be useful for making small patches, or for non-developers to contribute small fixes.

Done!
 * 1) Go to https://gerrit.wikimedia.org/r/?polygerrit=0#/admin/projects/foo replacing   with the code repository (e.g. https://gerrit.wikimedia.org/r/?polygerrit=0#/admin/projects/mediawiki/extensions/Echo )
 * 2) Click "Create Change"
 * 3) Set branch to "master" (if you don't want to use master branch you can use the other branches available for that project)
 * 4) Set the topic to something of your choosing (e.g. "copy-edit" - must be all-one-string) (optional)
 * 5) Write a description ("commit summary") in the big text field by following Gerrit/Commit message guidelines. (Example)
 * 6) Click "Create"
 * 7) Under "Files", click the "Edit" button
 * 8) Under "Files", click "Add"
 * 9) Type the folder/file path for the file you wish to edit (e.g. i18n/en.json) and click "Open"
 * 10) Find the line(s) you want to change, and change them.
 * 11) Click "Save"
 * 12) Click "Close"
 * 13) Click "Publish edit"
 * 14) Click the button "Start Review"

For steps 1-6 there is also an alternative way:
 * 1) Go to https://gerrit.wikimedia.org/r/#/projects/foo,dashboards/default (e.g. https://gerrit.wikimedia.org/r/#/projects/mediawiki/extensions/Echo,dashboards/default )
 * 2) Click the topmost patch under "Merged Changes" of the chosen branch (e.g. master)
 * 3) Click "Follow-Up"
 * 4) Write a description ("commit summary") in the big text field similarly as in the step 5 above
 * 5) Click "Follow-Up"
 * 6) Change the topic to something of your choosing (e.g. "copy-edit" - must be all-one-string) (optional)

If you need to change the commit summary, you can use these steps:
 * 1) Under "File Path", click "Commit Message"
 * 2) On top of the right panel, click the "Edit" button
 * 3) Make changes to the commit summary.
 * 4) Click "Save"
 * 5) Click "Close"
 * 6) Click "Publish edit"

How code is reviewed in Gerrit
Code review is an essential part of our contribution workflow. The principle is basic: any patch must be reviewed by others before being merged.

This means that your code will need reviewers. Check our advice for getting reviews.

Review before merge
It's important to us to have a review-before-merge workflow for MediaWiki core and also for any extension we deploy. We will also offer that option to any extension author who wants it for their extension. The one exception is localisation and internationalisation commits, which will be able to be pushed without review.

Who can review? Gerrit project owners
After creating a Developer account, anyone can comment on commits and express criticism and approvals. Anyone can give a nonbinding "+1" to any commit. However, for any given repository ("Gerrit project"), only a small group of people will have the ability to approve code within Gerrit and merge it into the repository. This superapproval is a "+2" even though that's a misleading name, because two +1 approvals DO NOT add up to a +2. These people are "Gerrit project owners".

How to comment on, review, and merge code in Gerrit








Anyone can comment on code in Gerrit.

Viewing and commenting on code

 * Make sure that you have a developer account.
 * Log in to Gerrit. If you know the changeset you want to look at (URL will look like https://gerrit.wikimedia.org/r/#/c/23939/ ), go to that. Otherwise, use the search box. You can search by author ("Owner"), Gerrit project, branch, changesets you've starred, etc. The Gerrit search documentation covers all of the different search operators you can use.
 * The changeset has a few fields, links and buttons:
 * Assignee. An optional field to make a single person responsible for handling reviewing the changeset. This should only be set if the assignee has agreed.
 * Reviewers. 'jenkins-bot' is the autoreviewer that auto-verifies anything that passes the Jenkins tests. It will report a red or green mark depending on whether the build passes.
 * The Add" button on the right of Reviewers:'''. Manually pings someone to request their review. It'll show up in their Gerrit dashboard.
 * Files: Open All. Opens the diff (each file in a separate browser tab). You can double-click on a line and then press C to comment on that line, then save a draft comment! Then, click the green "Up to change" arrow to go back to the changeset, and click "Reply…" to publish your comment.
 * Reply… ("Add comment"). Publish your thoughts on the commit, including an overall comment and/or inline comments you added (see above).
 * If, upon code review, you approve, use "+1" under "Reply…"; otherwise, use "-1" to disapprove. These numbers are nonbinding, won't cause merges or rejections, and have no formal effect on the code review.
 * Abandon (you'll see this if you wrote this diff). This action removes the diff from the list to review, but leaves it in Gerrit for archival purposes.

Comparing patch sets
Every time you amend your commit and submit it for review, a new patch set is created. You can compare the different patch sets like this:


 * Under Files, select either Open All or choose a specific file listed to open that file.
 * On the left side under Patch Set, Base is preselected. On the right of the screen under Patch Set, the latest patch set is preselected. Adjust the selected patch sets to your needs.

Formally reviewing and merging or rejecting code
If you are one of the Gerrit project owners, you'll also see:
 * Abandon button
 * under Reply, additional Code-Review options to +2 (approve) or -2 (veto) a diff, and a Post button (publish your comment and merge diff into the branch, in 1 step)
 * Submit button (merge -- only useful if you or someone else has already given a +2 approval to the diff, but not merged it)

And once you've merged something into the example Gerrit project you'll see it in https://gerrit.wikimedia.org/r/plugins/gitiles/test/mediawiki/extensions/examples/.

If you merged a commit that references a task in Phabricator and that commit is supposed to fix that task completely, please go to that task and change its status to "Resolved" (via the Add Action… 🡒 Change Status dropdown). Also reference the merge ID if gerritbot has not already posted it in that task.

Sorun giderme
For problems and how to solve them, see Gerrit/Troubleshooting.

Ayrıca bakınız
Also useful are these pages:
 * Download from Git
 * wikitech:Help:Getting Started
 * Gerrit
 * Gerrit/git-review
 * Gerrit/Tutorial/tl;dr
 * Gerrit/TortoiseGit tutorial
 * Wikimedia Gerrit Patch Uploader