Determines a unique release-name

@param string $release

@return string
480459
protected static function getUniqueReleaseName($release)
    {
        // Prevent duplicate release names
        $i = 0;
        $releaseName = $release;
        $cmdTemplate = '[ -d {{deploy_path}}/releases/%s ]';
        $cmd = sprintf($cmdTemplate, $releaseName);
        while (\Deployer\test($cmd)) {
            $releaseName = $release . '-' . ++$i;
            $cmd = sprintf($cmdTemplate, $releaseName);
        }

        return $releaseName;
    }
81206
protected function _getFileName($file)
    {
        $rename = [];
        foreach ($this->files as $value) {
            if ($value['source'] == '*') {
                if (!isset($rename['source'])) {
                    $rename           = $value;
                    $rename['source'] = $file;
                }
            }

            if ($value['source'] == $file) {
                $rename = $value;
                break;
            }
        }

        if (!isset($rename['source'])) {
            return $file;
        }

        if (!isset($rename['target']) || $rename['target'] == '*') {
            $rename['target'] = $rename['source'];
        }

        if (is_dir($rename['target'])) {
            $name = basename($rename['source']);
            $last = $rename['target'][strlen($rename['target']) - 1];
            if (($last != '/') && ($last != '\\')) {
                $rename['target'] .= DIRECTORY_SEPARATOR;
            }

            $rename['target'] .= $name;
        }

        if ($rename['randomize']) {
            $info = pathinfo($rename['target']);
            $newTarget = $info['dirname'] . DIRECTORY_SEPARATOR .
                $info['filename'] . uniqid('_');
            if (isset($info['extension'])) {
                $newTarget .= '.' . $info['extension'];
            }
            $rename['target'] = $newTarget;
        }

        return $rename;
    }
988736
protected function makeNameUnique($name, $uploadDir, $extension)
    {
        $prefix = $name;

        $suffix = 0;

        while (is_file(sprintf('%s%s%s.%s', $uploadDir, DIRECTORY_SEPARATOR, $name, $extension))) {
            $suffix++;
            $name = $prefix.'-'.$suffix;
        }

        return $name;
    }
37282
public static function get_name($tool) {
        $name = null;

        if (empty($tool->name)) {
            $toolcontext = \context::instance_by_id($tool->contextid);
            $name = $toolcontext->get_context_name();
        } else {
            $name = $tool->name;
        };

        return $name;
    }
729684
public static function getNameByConstant($constant)
    {
        switch ($constant) {
            case self::SINGLE:
                return 'single';
            break;

            case self::MULTIPLE:
                return 'multiple';
            break;

            case self::ORDERED:
                return 'ordered';
            break;

            case self::RECORD:
                return 'record';
            break;

            default:
                return false;
            break;
        }
    }
823294
public function addRelease(Release $release)
	{
		$name = strtolower($release->getName());
		$this->releases[$name] = $release;
		$this->sortReleases();
	}
697162
public function setFileName($filename)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setFileName($filename)->setLocked();
    } else {
      return parent::setFileName($filename);
    }
  }
189899
protected function createLink(Release $release)
	{
		$line = '';

		$link = $release->getLink();

		if ($link !== null)
		{
			$linkName = $release->getLinkName();
			$name = $release->getName();

			$reference = ($linkName === null) ? $name : $linkName;

			$line = "[$reference] $link\n";
		}

		return $line;
	}
508086
public function getTableName($table) {
        if (preg_match('#^`?\{[^\}]+\}.*$#', $table)) {
            return $this->sanitize(str_replace(['{', '}'], [$this->tablePrefix, ''], $table));
        } else {
            return $this->sanitize($table);
        }
    }
35821
protected function getTitleFromFilename(string $filename)
    {
        $withoutExtension = pathinfo($filename, PATHINFO_FILENAME);
        return $withoutExtension !== '' ? $withoutExtension : $filename;
    }
1270479
public function getExistingMigrationNames($destination)
	{
		if (isset($this->existing[$destination])) return $this->existing[$destination];

		return $this->existing[$destination] = array_map(function($file)
		{
			return substr(basename($file), 18);

		}, $this->files->files($destination));
	}
113549
private function gatherEnvironmentVariables(Release $release)
    {
        $this->environmentVariables = array(
            '%stage%' => $release->getWorkspace()->getHost()->getStage(),
            '%version%' => $release->getVersion(),
        );
    }
1081828
public function generateUniqueAliasFor(string $tableName) : string
    {
        $aliases = array_flip($this->getTakenAliases());
        if (!isset($aliases[$tableName])) {
            return $tableName;
        }

        $count = 1;
        do {
            $newTableName = $tableName . $count;
            $count++;
        } while (isset($aliases[$newTableName]));

        return $newTableName;
    }
658823
public static function getNameByConstant($constant)
    {
        switch ($constant) {
            case self::IDENTIFIER:
                return 'identifier';
            break;

            case self::BOOLEAN:
                return 'boolean';
            break;

            case self::INTEGER:
                return 'integer';
            break;

            case self::FLOAT:
                return 'float';
            break;

            case self::STRING:
                return 'string';
            break;

            case self::POINT:
                return 'point';
            break;

            case self::PAIR:
                return 'pair';
            break;

            case self::DIRECTED_PAIR:
                return 'directedPair';
            break;

            case self::DURATION:
                return 'duration';
            break;

            case self::FILE:
                return 'file';
            break;

            case self::URI:
                return 'uri';
            break;

            case self::INT_OR_IDENTIFIER:
                return 'intOrIdentifier';
            break;

            case self::COORDS:
                return 'coords';
            break;

            default:
                return false;
            break;
        }
    }
204516
public function col_eventname($event) {
        // Event name.
        if ($this->filterparams->logreader instanceof logstore_legacy\log\store) {
            // Hack for support of logstore_legacy.
            $eventname = $event->eventname;
        } else {
            $eventname = $event->get_name();
        }
        if ($url = $event->get_url()) {
            $eventname = $this->action_link($url, $eventname, 'action');
        }
        return $eventname;
    }
657258
public function buildCacheName($build)
    {
        $name = $this->buildFileName($build, false);
        if ($build->name() == $this->_invalidated) {
            return '~' . $name;
        }
        return $name;
    }
792079
protected function getStoreName(UploadedFile $file)
    {
        if ($this->useUniqueName) {
            return $this->generateUniqueName($file);
        }

        if ($this->useSequenceName) {
            return $this->generateSequenceName($file);
        }

        if ($this->name instanceof \Closure) {
            return $this->name->call($this, $file);
        }

        if (is_string($this->name)) {
            return $this->name;
        }

        return $file->getClientOriginalName();
    }