Skip to content

Commit

Permalink
Merge branch 'book-fa' of bundle-fa/fa.bundle into hugo
Browse files Browse the repository at this point in the history
  • Loading branch information
dscho authored and dscho committed Aug 19, 2024
2 parents 57ecded + 3027146 commit 229308c
Show file tree
Hide file tree
Showing 919 changed files with 29,617 additions and 0 deletions.
4 changes: 4 additions & 0 deletions external/book/content/book/fa/_index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
### DO NOT EDIT! Generated by script/update-book2.rb
redirect_to: book/fa/v2
---

Large diffs are not rendered by default.

456 changes: 456 additions & 0 deletions external/book/content/book/fa/v2/Customizing-Git-Git-Attributes.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions external/book/content/book/fa/v2/Customizing-Git-Git-Hooks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
---
### DO NOT EDIT! Generated by script/update-book2.rb
category: book
section: documentation
subsection: book
sidebar: book
book:
language_code: fa
chapter:
title: Customizing Git
number: 8
section:
title: Git Hooks
number: 3
cs_number: '8.3'
previous: book/fa/v2/Customizing-Git-Git-Attributes
next: book/fa/v2/Customizing-Git-An-Example-Git-Enforced-Policy
title: Git - Git Hooks
---
<h2 id="_git_hooks">Git Hooks</h2>
<div class="paragraph">
<p>
Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur.
There are two groups of these hooks: client-side and server-side.
Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits.
You can use these hooks for all sorts of reasons.</p>
</div>
<div class="sect3">
<h3 id="_installing_a_hook">Installing a Hook</h3>
<div class="paragraph">
<p>The hooks are all stored in the <code>hooks</code> subdirectory of the Git directory.
In most projects, that’s <code>.git/hooks</code>.
When you initialize a new repository with <code>git init</code>, Git populates the hooks directory with a bunch of example scripts, many of which are useful by themselves; but they also document the input values of each script.
All the examples are written as shell scripts, with some Perl thrown in, but any properly named executable scripts will work fine – you can write them in Ruby or Python or whatever language you are familiar with.
If you want to use the bundled hook scripts, you’ll have to rename them; their file names all end with <code>.sample</code>.</p>
</div>
<div class="paragraph">
<p>To enable a hook script, put a file in the <code>hooks</code> subdirectory of your .git directory that is named appropriately (without any extension) and is executable.
From that point forward, it should be called.
We’ll cover most of the major hook filenames here.</p>
</div>
</div>
<div class="sect3">
<h3 id="_client_side_hooks">Client-Side Hooks</h3>
<div class="paragraph">
<p>There are a lot of client-side hooks.
This section splits them into committing-workflow hooks, email-workflow scripts, and everything else.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<div class="title">یادداشت</div>
</td>
<td class="content">
<div class="paragraph">
<p>It’s important to note that client-side hooks are <strong>not</strong> copied when you clone a repository.
If your intent with these scripts is to enforce a policy, you’ll probably want to do that on the server side; see the example in <a href="{{< relurl "book/fa/v2/ch00/_an_example_git_enforced_policy" >}}">An Example Git-Enforced Policy</a>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect4">
<h4 id="_committing_workflow_hooks">Committing-Workflow Hooks</h4>
<div class="paragraph">
<p>The first four hooks have to do with the committing process.</p>
</div>
<div class="paragraph">
<p>The <code>pre-commit</code> hook is run first, before you even type in a commit message.
It’s used to inspect the snapshot that’s about to be committed, to see if you’ve forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
Exiting non-zero from this hook aborts the commit, although you can bypass it with <code>git commit --no-verify</code>.
You can do things like check for code style (run <code>lint</code> or something equivalent), check for trailing whitespace (the default hook does exactly this), or check for appropriate documentation on new methods.</p>
</div>
<div class="paragraph">
<p>The <code>prepare-commit-msg</code> hook is run before the commit message editor is fired up but after the default message is created.
It lets you edit the default message before the commit author sees it.
This hook takes a few parameters: the path to the file that holds the commit message so far, the type of commit, and the commit SHA-1 if this is an amended commit.
This hook generally isn’t useful for normal commits; rather, it’s good for commits where the default message is auto-generated, such as templated commit messages, merge commits, squashed commits, and amended commits.
You may use it in conjunction with a commit template to programmatically insert information.</p>
</div>
<div class="paragraph">
<p>The <code>commit-msg</code> hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer.
If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.
In the last section of this chapter, we’ll demonstrate using this hook to check that your commit message is conformant to a required pattern.</p>
</div>
<div class="paragraph">
<p>After the entire commit process is completed, the <code>post-commit</code> hook runs.
It doesn’t take any parameters, but you can easily get the last commit by running <code>git log -1 HEAD</code>.
Generally, this script is used for notification or something similar.</p>
</div>
</div>
<div class="sect4">
<h4 id="_email_hooks">Email Workflow Hooks</h4>
<div class="paragraph">
<p>You can set up three client-side hooks for an email-based workflow.
They’re all invoked by the <code>git am</code> command, so if you aren’t using that command in your workflow, you can safely skip to the next section.
If you’re taking patches over email prepared by <code>git format-patch</code>, then some of these may be helpful to you.</p>
</div>
<div class="paragraph">
<p>The first hook that is run is <code>applypatch-msg</code>.
It takes a single argument: the name of the temporary file that contains the proposed commit message.
Git aborts the patch if this script exits non-zero.
You can use this to make sure a commit message is properly formatted, or to normalize the message by having the script edit it in place.</p>
</div>
<div class="paragraph">
<p>The next hook to run when applying patches via <code>git am</code> is <code>pre-applypatch</code>.
Somewhat confusingly, it is run <em>after</em> the patch is applied but before a commit is made, so you can use it to inspect the snapshot before making the commit.
You can run tests or otherwise inspect the working tree with this script.
If something is missing or the tests don’t pass, exiting non-zero aborts the <code>git am</code> script without committing the patch.</p>
</div>
<div class="paragraph">
<p>The last hook to run during a <code>git am</code> operation is <code>post-applypatch</code>, which runs after the commit is made.
You can use it to notify a group or the author of the patch you pulled in that you’ve done so.
You can’t stop the patching process with this script.</p>
</div>
</div>
<div class="sect4">
<h4 id="_other_client_hooks">Other Client Hooks</h4>
<div class="paragraph">
<p>The <code>pre-rebase</code> hook runs before you rebase anything and can halt the process by exiting non-zero.
You can use this hook to disallow rebasing any commits that have already been pushed.
The example <code>pre-rebase</code> hook that Git installs does this, although it makes some assumptions that may not match with your workflow.</p>
</div>
<div class="paragraph">
<p>The <code>post-rewrite</code> hook is run by commands that replace commits, such as <code>git commit --amend</code> and <code>git rebase</code> (though not by <code>git filter-branch</code>).
Its single argument is which command triggered the rewrite, and it receives a list of rewrites on <code>stdin</code>.
This hook has many of the same uses as the <code>post-checkout</code> and <code>post-merge</code> hooks.</p>
</div>
<div class="paragraph">
<p>After you run a successful <code>git checkout</code>, the <code>post-checkout</code> hook runs; you can use it to set up your working directory properly for your project environment.
This may mean moving in large binary files that you don’t want source controlled, auto-generating documentation, or something along those lines.</p>
</div>
<div class="paragraph">
<p>The <code>post-merge</code> hook runs after a successful <code>merge</code> command.
You can use it to restore data in the working tree that Git can’t track, such as permissions data.
This hook can likewise validate the presence of files external to Git control that you may want copied in when the working tree changes.</p>
</div>
<div class="paragraph">
<p>The <code>pre-push</code> hook runs during <code>git push</code>, after the remote refs have been updated but before any objects have been transferred.
It receives the name and location of the remote as parameters, and a list of to-be-updated refs through <code>stdin</code>.
You can use it to validate a set of ref updates before a push occurs (a non-zero exit code will abort the push).</p>
</div>
<div class="paragraph">
<p>Git occasionally does garbage collection as part of its normal operation, by invoking <code>git gc --auto</code>.
The <code>pre-auto-gc</code> hook is invoked just before the garbage collection takes place, and can be used to notify you that this is happening, or to abort the collection if now isn’t a good time.</p>
</div>
</div>
</div>
<div class="sect3">
<h3 id="_server_side_hooks">Server-Side Hooks</h3>
<div class="paragraph">
<p>In addition to the client-side hooks, you can use a couple of important server-side hooks as a system administrator to enforce nearly any kind of policy for your project.
These scripts run before and after pushes to the server.
The pre hooks can exit non-zero at any time to reject the push as well as print an error message back to the client; you can set up a push policy that’s as complex as you wish.</p>
</div>
<div class="sect4">
<h4 id="_pre_receive"><code>pre-receive</code></h4>
<div class="paragraph">
<p>The first script to run when handling a push from a client is <code>pre-receive</code>.
It takes a list of references that are being pushed from stdin; if it exits non-zero, none of them are accepted.
You can use this hook to do things like make sure none of the updated references are non-fast-forwards, or to do access control for all the refs and files they’re modifying with the push.</p>
</div>
</div>
<div class="sect4">
<h4 id="_update"><code>update</code></h4>
<div class="paragraph">
<p>The <code>update</code> script is very similar to the <code>pre-receive</code> script, except that it’s run once for each branch the pusher is trying to update.
If the pusher is trying to push to multiple branches, <code>pre-receive</code> runs only once, whereas update runs once per branch they’re pushing to.
Instead of reading from stdin, this script takes three arguments: the name of the reference (branch), the SHA-1 that reference pointed to before the push, and the SHA-1 the user is trying to push.
If the update script exits non-zero, only that reference is rejected; other references can still be updated.</p>
</div>
</div>
<div class="sect4">
<h4 id="_post_receive"><code>post-receive</code></h4>
<div class="paragraph">
<p>The <code>post-receive</code> hook runs after the entire process is completed and can be used to update other services or notify users.
It takes the same stdin data as the <code>pre-receive</code> hook.
Examples include emailing a list, notifying a continuous integration server, or updating a ticket-tracking system – you can even parse the commit messages to see if any tickets need to be opened, modified, or closed.
This script can’t stop the push process, but the client doesn’t disconnect until it has completed, so be careful if you try to do anything that may take a long time.</p>
</div>
</div>
</div>
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
26 changes: 26 additions & 0 deletions external/book/content/book/fa/v2/Customizing-Git-Summary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
### DO NOT EDIT! Generated by script/update-book2.rb
category: book
section: documentation
subsection: book
sidebar: book
book:
language_code: fa
chapter:
title: Customizing Git
number: 8
section:
title: Summary
number: 5
cs_number: '8.5'
previous: book/fa/v2/Customizing-Git-An-Example-Git-Enforced-Policy
next: book/fa/v2/Git-and-Other-Systems-Git-as-a-Client
title: Git - Summary
---
<h2 id="_summary_4">Summary</h2>
<div class="paragraph">
<p>We’ve covered most of the major ways that you can customize your Git client and server to best fit your workflow and projects.
You’ve learned about all sorts of configuration settings, file-based attributes, and event hooks, and you’ve built an example policy-enforcing server.
You should now be able to make Git fit nearly any workflow you can dream up.</p>
</div>
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
Loading

0 comments on commit 229308c

Please sign in to comment.