-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
106 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/components/Generator/GeneredTaskfile/addons/git/git-link-hooks.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function project:git-config { | ||
title "Setting git configuration" | ||
git config --local core.hooksPath dev/git-hooks | ||
echo -e "Git hooks directory is set to ${YELLOW}./dev/git-hooks${RESET}." | ||
} |
25 changes: 25 additions & 0 deletions
25
src/components/Generator/GeneredTaskfile/addons/git/git.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { GeneratorSettings } from '@/components/Generator'; | ||
import { TaskfileAddons } from '@/components/Generator/GeneredTaskfile/taskfile'; | ||
import loadTemplate from '@/helpers/loadTemplate'; | ||
import gitLinkHooks from './git-link-hooks.sh'; | ||
import githubFunction from './github-pr-function.sh'; | ||
import gitlabFunction from './gitlab-mr-function.sh'; | ||
|
||
const git = (settings: GeneratorSettings, addon: TaskfileAddons): void => { | ||
if (settings.linkGitHooks) { | ||
addon.projectFunctions.push(loadTemplate(gitLinkHooks)); | ||
|
||
addon.initCheckCommands.push('project:git-config'); | ||
} | ||
|
||
switch (settings.checkoutGitRequest) { | ||
case 'github': | ||
addon.projectFunctions.push(loadTemplate(githubFunction)); | ||
break; | ||
case 'gitlab': | ||
addon.projectFunctions.push(loadTemplate(gitlabFunction)); | ||
break; | ||
} | ||
} | ||
|
||
export default git; |
16 changes: 16 additions & 0 deletions
16
src/components/Generator/GeneredTaskfile/addons/git/github-pr-function.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function task:pr { ## Check out pull request <number> and update | ||
project:checkout-pr $1 | ||
project:update | ||
} | ||
|
||
function project:checkout-pr { | ||
title "Checking out pull request" | ||
if [ -z "$1" ]; then | ||
echo "You need to provide a pull request number to check out." | ||
echo -e "${BLUE}Usage:${RESET} $0 pr ${YELLOW}<number>${RESET}" | ||
exit 1 | ||
fi | ||
echo "Checking out pull request $1..." | ||
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 | ||
git checkout origin/pr/$1 | ||
} |
16 changes: 16 additions & 0 deletions
16
src/components/Generator/GeneredTaskfile/addons/git/gitlab-mr-function.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function task:mr { ## Check out merge request <number> and update | ||
project:checkout-mr $1 | ||
project:update | ||
} | ||
|
||
function project:checkout-mr { | ||
title "Checking out merge request" | ||
if [ -z "$1" ]; then | ||
echo "You need to provide a merge request number to check out." | ||
echo -e "${BLUE}Usage:${RESET} $0 mr ${YELLOW}<number>${RESET}" | ||
exit 1 | ||
fi | ||
echo "Checking out merge request $1..." | ||
git fetch origin refs/merge-requests/$1/head:refs/remotes/origin/merge-requests/$1 | ||
git checkout origin/merge-requests/$1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {default} from './git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters