Commit 01f69738 authored by Fran Garcia-Linares's avatar Fran Garcia-Linares Committed by Neil Drumm
Browse files

Issue #3300976: Incorrect message of empty repository

parent 444a47ce
Loading
Loading
Loading
Loading
+191 −170
Original line number Diff line number Diff line
@@ -161,20 +161,17 @@ function project_git_instructions_project_tab($node, $version = NULL, $do_nonmai
    $is_maintainer = FALSE;
  }

  // Grab the default replacement patterns.
  // Prepare the text blocks.
  $defaults = project_git_instructions_get_defaults($node, $version);
  if ($is_maintainer && empty($GLOBALS['user']->git_username)) {
    return t('<h1>Account Settings Missing</h1>
  $git_username_missing = t('<h1>Account settings missing</h1>
  <p>Your Git username has not been set yet. Please set one at the !git_access_link.</p>', $defaults);
  }
  elseif ($has_versions) {
    if ($is_maintainer) {
      $content[] = ['#markup' => t('<h2>One-Time Only</h2>

  $full_instructions = t('<h2>One-time only</h2>
  <h3>Setting up this repository in your local environment for the first time</h3>
  If you have just created a project or you already have a local repository, skip this step.
  <div class="codeblock">
  <code>git clone@branch @auth_project_url</code><br>
<code>cd @uri</code><br />
  <code>cd @uri</code>
  </div>
  Not working for you? See <a href="/node/1065850">Troubleshooting Git clone</a>. Once it works, you need the <a href="/project/git_deploy">Git deploy</a> module. See <a href="/node/1314752">Versioned dependencies and Git</a> for an explanation.

@@ -183,25 +180,26 @@ The headings below are not sequential. What you choose to do depends on where yo
  <h3>Checking your repository status</h3>
  To see what you will commit by running <code>git commit</code> and what you could commit by running <code>git add</code> before running <code>git commit</code>.
  <div class="codeblock">
<code>git status</code><br />
  <code>git status</code>
  </div>
  <h3>Switching to a different branch</h3>
  When you clone the repository you have access to all the branches and tags. The first command shows your choices. The second command makes the switch. See <a href="/node/1066342">branching and tagging</a> for details.
  <div class="codeblock">
<code>git branch -a</code><br />
<code>git checkout [branchname]</code><br />
  <code>git branch -a</code><br>
  <code>git checkout [branchname]</code>
  </div>

  <h3>Committing all changes locally</h3>
  After making changes, add and commit them. Do not begin commit messages with the # symbol. See <a href="/node/52287">Commit messages</a> for details.
  <div class="codeblock">
<code>git add -A</code><br />
  <code>git add -A</code><br>
  <code>git commit -m &quot;Issue #[issue number] by [comma-separated usernames]: [Short summary of the change].&quot;</code>
  </div>
  <h3>Pushing your code back to the repository on Drupal.org</h3>
  <div class="codeblock">
  <code>git push -u origin HEAD</code>
  </div>

  <h2>Patching</h2>
  <p>Contributing changes with patches is being replaced with <a href="/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests">issue forks and merge requests</a>.</p>
  <h3>Getting ready to create or apply patches</h3>
@@ -213,54 +211,86 @@ If you have not already cloned the repository, follow the directions above for s
  <h3>Creating a patch</h3>
  For most improvements, use the following command after making your changes:
  <div class="codeblock">
<code>git diff > [description]-[issue-number]-[comment-number].patch</code><br />
  <code>git diff > [description]-[issue-number]-[comment-number].patch</code>
  </div>
  For more complex improvements that require adding/removing files, work over the course of multiple days including Git commits, or collaboration with others, see the <a href="/node/1054616">Advanced patch workflow</a>.

  <h3>Applying a patch </h3>
  Download the patch to your working directory. Apply the patch with the following command:
  <div class="codeblock">
<code>git apply -v [patchname.patch]</code><br />
  <code>git apply -v [patchname.patch]</code>
  </div>

  To avoid accidentally including the patch file in future commits, remove it:
  <div class="codeblock">
<code>rm [patchname.patch]</code><br />
  <code>rm [patchname.patch]</code>
  </div>

  <h3>When you’re done: Reverting uncommited changes</h3>
  Revert changes to a specific file:
  <div class="codeblock">
<code>git checkout [filename]</code><br />
  <code>git checkout [filename]</code>
  </div>

  Revert changes to the whole working tree:
  <div class="codeblock">
<code>git reset --hard</code><br />
  <code>git reset --hard</code>
  </div>

<h2>Creating Releases</h2>
See the <a href="/node/1015226">naming conventions</a> for a complete description of how to name branches and tags so you can create releases.
  <h2>Creating releases</h2>
  See the <a href="!naming-conventions-url">naming conventions</a> for a complete description of how to name branches and tags so you can create releases.
  <h3>Branch for a dev release</h3>
  This creates and checks out a new branch in one command, then pushes it to Drupal.org
  <div class="codeblock">
<code>git checkout -b @newbranch</code><br />
<code>git push -u origin @newbranch</code><br />
  <code>git checkout -b @newbranch</code><br>
  <code>git push -u origin @newbranch</code>
  </div>

  <h3>Tag for a stable release</h3>
  <div class="codeblock"><code>git tag [tag name]
  git push origin tag [tag name]</code></div>

<p>Once you’ve pushed the properly-formed tag or branch, see <a href="/node/1068944">Creating a project release</a> for directions to actually create the release node.</p>', $defaults)];
    }
    else {
      // Is not maintainer.
      $content[] = ['#markup' => t('<h2>One-Time Only</h2>
  <p>Once you’ve pushed the properly-formed tag or branch, see <a href="!creating-release-url">Creating a project release</a> for directions to actually create the release node.</p>', $defaults + [
    '!naming-conventions-url' => url('node/1015226'),
    '!creating-release-url' => url('node/1068944'),
  ]);

  $empty_or_no_versions = t('<h2>Empty repository</h2>
  <h3>Setting up this repository for the first time</h3>
  <p>See <a href="!git-authentication-url">Git Authentication for Drupal.org Projects</a> for information about setting up SSH keys and other ways to authenticate.</p>
  <div class="codeblock">
  <code>mkdir @uri</code><br><br>
  <code>cd @uri</code><br><br>
  <code>git init</code><br><br>
  <code>git checkout -b @newbranch</code><br><br>
  <code>echo "%title" > README.txt</code><br><br>
  <code>git add README.txt</code><br><br>
  <code>git commit -m "Initial commit."</code><br><br>
  <code>git remote add origin @auth_project_url</code><br><br>
  <code>git push origin @newbranch</code>
  </div>
  <p>When you’ve completed these steps, create a (dev) release and then <a href="">refresh this page</a> for further direction.</p>

  <p><strong>Note:</strong> You have created a local repository. You will not need to complete the One-Time clone on the next page unless you delete your local repository or set up on a different machine. Then, you’ll need to perform the One-time setup, as will co-maintainers.</p>

  <h2>Creating releases</h2>
  See the <a href="!naming-conventions-url">naming conventions</a> for a complete description of how to name branches and tags so you can create releases.
  <h3>Branch for a dev release</h3>
  This creates and checks out a new branch in one command, then pushes it to Drupal.org
  <div class="codeblock">
  <code>git push -u origin @newbranch</code>
  </div>
  <p>Once you’ve pushed the properly-formed branch, see <a href="!creating-release-url">Creating a project release</a> for directions to actually create the release node.</p>', $defaults + [
    '!git-authentication-url' => url('node/2980776'),
    '!naming-conventions-url' => url('node/1015226'),
    '!creating-release-url' => url('node/1068944'),
  ]);

  $partial_instructions = t('<h2>One-time only</h2>
  <h3>Setting up repository for the first time</h3>
  <div class="codeblock">
  <code>git clone@branch @anon_project_url</code><br>
<code>cd @uri</code><br />
  <code>cd @uri</code>
  </div>
  Not working for you? See <a href="/node/1065850">Troubleshooting Git clone</a>. Once it works, you need the <a href="/project/git_deploy">Git deploy</a> module. See <a href="/node/1314752">Versioned dependencies and Git</a> for an explanation.
  <h2>Routinely</h2>
@@ -268,13 +298,13 @@ The headings below are not sequential. What you choose to do depends on where yo
  <h3>Checking your repository status</h3>
  To see what you will commit by running <code>git commit</code> and what you could commit by running <code>git add</code> before running <code>git commit</code>.
  <div class="codeblock">
<code>git status</code><br />
  <code>git status</code>
  </div>
  <h3>Switching to a different branch</h3>
  When you clone the repository you have access to all the branches and tags. The first command shows your choices. The second command makes the switch. See <a href="/node/1066342">branching and tagging</a> for details.
  <div class="codeblock">
<code>git branch -a</code><br />
<code>git checkout [branchname]</code><br />
  <code>git branch -a</code><br>
  <code>git checkout [branchname]</code>
  </div>
  <h2>Patching</h2>
  <p>Contributing changes with patches is being replaced with <a href="/docs/develop/git/using-git-to-contribute-to-drupal/creating-issue-forks-and-merge-requests">issue forks and merge requests</a>.</p>
@@ -287,57 +317,48 @@ If you have not already cloned the repository, follow the directions above for s
  <h3>Creating a patch</h3>
  For most improvements, use the following command after making your changes:
  <div class="codeblock">
<code>git diff > [description]-[issue-number]-[comment-number].patch</code><br />
  <code>git diff > [description]-[issue-number]-[comment-number].patch</code>
  </div>
  For more complex improvements that require adding/removing files, work over the course of multiple days including Git commits, or collaboration with others, see the <a href="/node/1054616">Advanced patch workflow</a>.

  <h3>Applying a patch</h3>
  Download the patch to your working directory. Apply the patch with the following command:
  <div class="codeblock">
<code>git apply -v [patchname.patch]</code><br />
  <code>git apply -v [patchname.patch]</code>
  </div>

  To avoid accidentally including the patch file in future commits, remove it:
  <div class="codeblock">
<code>rm [patchname.patch]</code><br />
  <code>rm [patchname.patch]</code>
  </div>

  <h3>When you’re done: Reverting uncommited changes</h3>
  Revert changes to a specific file:
  <div class="codeblock">
<code>git checkout [filename]</code><br />
  <code>git checkout [filename]</code>
  </div>

  Revert changes to the whole working tree:
  <div class="codeblock">
<code>git reset --hard</code><br />
</div>', $defaults)];
    }
  }
  else { // !$has_versions
    if ($is_maintainer) {
      $content[] = ['#markup' => t('<h2>Empty Repository</h2>
<h3>Setting up this repository for the first time</h3>
<p>See <a href="/node/1027094">Git Authentication for Drupal.org Projects</a> for information about setting up SSH keys and other ways to authenticate.</p>
<div class="codeblock">
<code>mkdir @uri</code><br /><br />
<code>cd @uri</code><br /><br />
<code>git init</code><br /><br />
<code>git checkout -b @newbranch</code><br /><br />
<code>echo "%title" > README.txt</code><br /><br />
<code>git add README.txt</code><br /><br />
<code>git commit -m "Initial commit."</code><br /><br />
<code>git remote add origin @auth_project_url</code><br /><br />
<code>git push origin @newbranch</code><br />
</div>
<p>When you’ve completed these steps, <a href="">refresh this page</a> for further direction.</p>
  <code>git reset --hard</code>
  </div>', $defaults);

<p><strong>Note:</strong> You have created a local repository. You will not need to complete the One-Time clone on the next page unless you delete your local repository or set up on a different machine. Then, you’ll need to perform the One-time setup, as will co-maintainers.</p>', $defaults)];
  // Grab the default replacement patterns.
  if ($is_maintainer && empty($GLOBALS['user']->git_username)) {
    return $git_username_missing;
  }
  elseif ($is_maintainer) {
    if ($has_versions) {
      $content[] = ['#markup' => $full_instructions];
    }
    else {
      $content[] = ['#markup' => t('<h2>Empty Repository</h2>
<p>No code is available for %title. <a href="/project/issues/@uri?categories=All">File an issue</a> or contact a maintainer if you have questions.</p>', $defaults)];
      // !$has_versions && $is_maintainer
      $content[] = ['#markup' => $empty_or_no_versions];
    }
  }
  else {
    // Is not maintainer.
    $content[] = ['#markup' => $partial_instructions];
  }

  return $content;