Creates the appropriate .gitignore file for a Symfony project if it doesn't exist.

@return $this
776274
protected function createGitIgnore()
    {
        if (!is_file($path = $this->projectDir.'/.gitignore')) {
            try {
                $client = $this->getGuzzleClient();

                $response = $client->get(sprintf(
                    'https://raw.githubusercontent.com/symfony/symfony-standard/v%s/.gitignore',
                    $this->getInstalledSymfonyVersion()
                ));

                $this->fs->dumpFile($path, $response->getBody()->getContents());
            } catch (\Exception $e) {
                // don't throw an exception in case the .gitignore file cannot be created,
                // because this is just an enhancement, not something mandatory for the project
            }
        }

        return $this;
    }
664446
def prepare
      raise AlreadyPreparedError.new(@path) if prepared?
      in_work_tree :tmp do
        FileUtils.touch '.silo'
        @git.add '.silo'
        @git.commit_index 'Enabled Silo for this repository'
      end
    end
877503
public function main()
    {
        $gitignoreFiles     = $this->gitignoreFiles;
        $gitignoreMerged    = array();
        $gitignoreFileArray = array();

        if (!empty($gitignoreFiles) && is_array($gitignoreFiles)) {
            foreach ($gitignoreFiles as $gitignoreFile) {
                if (is_file($gitignoreFile)) {
                    $gitignoreFileArray = array_merge(
                        $gitignoreFileArray,
                        file(
                            $gitignoreFile,
                            (FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
                        )
                    );
                }
            }
        }

        foreach ($gitignoreFileArray as $gitignoreLine) {
            if (strpos($gitignoreLine, '#') === 0) {
                $section = $gitignoreLine;
                if (!isset($gitignoreMerged[$section])) {
                    $gitignoreMerged[$section] = array();
                }
            } else {
                $gitignoreMerged[$section][] = $gitignoreLine;
            }
        }

        asort($gitignoreMerged);
        foreach ($gitignoreMerged as &$merged) {
            $merged = array_unique($merged);
            sort($merged);
        }

    }
987985
private function cloneFromGit()
    {
        $this->tmpDirectory = tmpPath().'/'.time();
        GitRepository::cloneRepository($this->argument('source'), $this->tmpDirectory);
        return $this;
    }
1207245
public function makeRelative() {
    $this->cygwin = FALSE;
    $this->wrapper = NULL;
    $this->prefix = NULL;
    return $this;
  }
758149
private function doSymLinks()
    {
        if(config('deploy.symlinks')) {

            $this->comment("\n\nCreating symlinks");
            foreach(config('deploy.symlinks') as $target => $link){
                if (file_exists($link)) {
                    $this->comment('The '.$link.' directory already exists.');
                }else{
                    $this->laravel->make('files')->link(
                        $target, $link
                    );
                }
            }

            $this->info("Symlinks created");
        }

        return $this;
    }
433944
private function cloneFromGit()
    {
        $this->tmpDirectory = tmpPath().'/'.time();
        GitRepository::cloneRepository($this->gitURL, $this->tmpDirectory);
        return $this;
    }
370029
public static function bundle(string $root = "", string $ignore = ""): void
    {
        echo "Bundling...\n";

        $root = realpath($root ?: self::rootPath());
        $ignore = realpath($ignore ?: self::rootPath()."/.zipignore");

        $archive_name = basename($root);
        $archive_path = $root."/zip/";

        echo "$archive_path => $archive_name.zip\n";

        $directory = new \RecursiveDirectoryIterator($archive_path);
        $file_info = new \RecursiveIteratorIterator($directory);

        $files = [];
        foreach ($file_info as $info)
        {
            $real_path = $info->getPathname();
            $file_name = $info->getFilename();

            // Skip /. and /..
            if($file_name === "." || $file_name === "..")
                continue;

            $path = str_replace($root, "", $real_path); // Remove base path from the path string.
            $path = str_replace("\\", "/", $path); // Match .zipignore format
            $path = substr($path, 1, strlen($path) - 1);

            if (!self::inIgnoreFile($path, $ignore))
            {
                $files[] = $path;
                echo "ADDED  : $path\n";
            }
            else
                echo "IGNORED: $path\n";
        }

        $zip = new \ZipArchive();
        $file_name = $root."/$archive_name.zip";

        if ($zip->open($file_name, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) !== true) {
            exit("Unable to create $file_name!\n");
        }

        // Save the current working directory and move to the root of the project for the next steps!
        $old_dir = getcwd();
        chdir($root);

        // Loop through each file in the list...
        foreach ($files as $file) {
            // Ensure .zipignore directory separators are converted to OS separators.
            //$path = str_replace("/", DIRECTORY_SEPARATOR, $file);
            $path = $file;

            // Remove the leading folder, as we do not want that structure in the ZIP archive.
            $local = str_replace("zip/", "", $path);

            // Add the file to the archive.
            $zip->addFile($path, $local);
        }

        $total_files = $zip->numFiles;
        $status = $zip->status !== 0 ? $zip->getStatusString() : "SUCCESS!";

        echo "FILES  : $total_files\n";
        echo "STATUS : $status\n";

        // Close the archive, we're all finished!
        $zip->close();

        // Return to the previous working directory.
        chdir($old_dir);
    }
1123123
protected function createEmailPreviewDirectory()
    {
        if (! $this->files->exists($this->previewPath)) {
            $this->files->makeDirectory($this->previewPath);

            $this->files->put($this->previewPath.'/.gitignore', "*\n!.gitignore");
        }
    }
1237013
function addGitIgnore(rootFolder) {

    // If no .gitignore files exists, add one
    const gitignore = path.join(rootFolder, '.gitignore');
    if (!fs.existsSync(gitignore)) {
        fs.writeFileSync(gitignore, gitignoreContent);
    }
}
1097035
protected function saveDrupalUuid()
    {
        $config = ProjectX::getProjectConfig();
        $options[static::getTypeId()] = [
            'build_info' => [
                'uuid' => $this->getDrupalUuid()
            ]
        ];

        $config
            ->setOptions($options)
            ->save(ProjectX::getProjectPath());

        return $this;
    }
235047
def ignore_generated_fixtures
      ignore_file = File.join(Rails.root, FIXTURE_DIRECTORY, '../.gitignore')
      return if File.exists?(ignore_file)
      File.open(ignore_file, 'w') do |file|
        file.puts('generated')
      end
    end
1296117
protected function prepareDir() {
    $this->say("Preparing artifact directory...");
    $deploy_dir = $this->deployDir;
    $this->taskDeleteDir($deploy_dir)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();
    $this->taskFilesystemStack()
      ->mkdir($this->deployDir)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->stopOnFail()
      ->run();
    $this->taskExecStack()
      ->dir($deploy_dir)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->stopOnFail()
      ->exec("git init")
      ->exec("git config --local core.excludesfile false")
      ->exec("git config --local core.fileMode true")
      ->run();
    $this->say("Global .gitignore file is being disabled for this repository to prevent unexpected behavior.");
  }
1044957
private function createDefaultTheme()
    {
        $this->info("Creating default theme...");

        // Delete default theme, so we later get the latest version from git
        $defaultThemePath = base_path('themes/'.config('project.defaultTheme'));

        if(file_exists($defaultThemePath)) {
            File::deleteDirectory($defaultThemePath);
        }else{
            (new DummyTheme(
                [
                'title' => 'Default Theme',
                'namespace' => 'DefaultTheme',
                'organisation' => 'Manaferra',
                'authorName' => 'Faton Sopa',
                'authorEmail' => 'fatom.sopa@manaferra.com',
                'auth' => true,
                'activate' => true,
                ]
            ))->make();
        }

        $this->advanceBar();

        return $this;
    }
1314640
public function save()
    {
        if ($path = $this->getProjectPath()) {
            $path .= '/' . $this->getOutputFile();
            file_put_contents($path, serialize($this->getContainer()));
        } else {
            throw new \RuntimeException('No project path provided.');
        }
        return $this;
    }
318750
public function onPrePersist() {
    $this->generateSlugs();

    if (!isset($this->created)) {
      $this->created = \Psc\DateTime\DateTime::now();
    }
    $this->updated = \Psc\DateTime\DateTime::now();

    return $this;
  }
155865
public function getPersistence()
    {
        $persistence = $this->getContainer()->get('liip.translation.persistence');

        if (false === $persistence instanceof GitPersistence) {
            throw new \RuntimeException(sprintf(
                'Cannot initialize git repository, configured persistence should be "%s", "%s" given',
                'Liip\TranslationBundle\Persistence\GitPersistence',
                get_class($persistence)
            ));
        }

        return $persistence;
    }