Skip to content

Commit

Permalink
Merge pull request #24 from moderntribe/feature/more-than-github
Browse files Browse the repository at this point in the history
GitLab, BitBucket, custom domain
  • Loading branch information
borkweb authored Jun 30, 2020
2 parents f6d7ddf + 32afccd commit 5aa7adc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
6 changes: 4 additions & 2 deletions .env.tric
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ CLI_VERBOSITY=0
# TRIC_CURRENT_PROJECT_RELATIVE_PATH=
# When you `use` on a supported subdirectory of a plugin, this stores the subdirectory name.
#TRIC_CURRENT_PROJECT_SUBDIR=
# The GitHub handle of the company to clone plugins from.
TRIC_GITHUB_COMPANY_HANDLE=moderntribe
# The git domain from which to clone plugins.
TRIC_GIT_DOMAIN=github.com
# The git handle from which to clone plugins.
TRIC_GIT_HANDLE=moderntribe

# The path where `tric here` was executed.
# TRIC_HERE_DIR=
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.5] - 2020-06-30
### Changed

- Allow for additional git upstreams other than GitHub.

## [0.4.4] - 2020-06-29
### Changed

Expand Down
32 changes: 24 additions & 8 deletions src/tric.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,12 @@ function clone_plugin( $plugin, $branch = null ) {

echo "Cloning {$plugin}...\n";

$repository = github_company_handle() . '/' . escapeshellcmd( $plugin );
$repository = git_handle() . '/' . escapeshellcmd( $plugin );

$clone_command = sprintf(
'git clone %s --recursive git@github.com:%s.git %s',
'git clone %s --recursive git@%s:%s.git %s',
null !== $branch ? '-b "' . $branch . '"' : '',
git_domain(),
$repository,
escapeshellcmd( $plugin_path )
);
Expand Down Expand Up @@ -414,14 +415,28 @@ function setup_plugin_tests( $plugin ) {
}

/**
* Returns the handle (username) of the company to clone plugins from.
* Returns the git domain from which to clone git plugins.
*
* Configured using the `TRIC_GITHUB_COMPANY_HANDLE` env variable.
* Configured using the `TRIC_GIT_DOMAIN` env variable.
* Examples: gitlab.com, bitbucket.org, git.example.com
*
* @return string The handle of the company to clone plugins from.
* @return string The git domain from which to clone plugins.
*/
function github_company_handle() {
$handle = getenv( 'TRIC_GITHUB_COMPANY_HANDLE' );
function git_domain() {
$domain = getenv( 'TRIC_GIT_DOMAIN' );

return ! empty( $domain ) ? trim( $domain ) : 'github.com';
}

/**
* Returns the handle (username) of the company from which to clone git plugins.
*
* Configured using the `TRIC_GIT_HANDLE` env variable.
*
* @return string The git handle from which to clone plugins.
*/
function git_handle() {
$handle = getenv( 'TRIC_GIT_HANDLE' );

return ! empty( $handle ) ? trim( $handle ) : 'moderntribe';
}
Expand Down Expand Up @@ -488,7 +503,8 @@ function tric_info() {
'CLI_VERBOSITY',
'TRIC_CURRENT_PROJECT',
'TRIC_CURRENT_PROJECT_RELATIVE_PATH',
'TRIC_GITHUB_COMPANY_HANDLE',
'TRIC_GIT_DOMAIN',
'TRIC_GIT_HANDLE',
'TRIC_HERE_DIR',
'TRIC_PLUGINS_DIR',
'TRIC_THEMES_DIR',
Expand Down
2 changes: 1 addition & 1 deletion tric
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $args = args( [
] );

$cli_name = basename( $argv[0] );
const CLI_VERSION = '0.4.4';
const CLI_VERSION = '0.4.5';

$cli_header = implode( ' - ', [
light_cyan( $cli_name ) . ' version ' . light_cyan( CLI_VERSION ),
Expand Down

0 comments on commit 5aa7adc

Please sign in to comment.