Skip to content

Commit

Permalink
Add git-hook subcommand, deprecate githook script
Browse files Browse the repository at this point in the history
  • Loading branch information
David Dooling committed Aug 14, 2018
1 parent 415a826 commit b226b91
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/atomist/cli/compare/0.5.2...HEAD)

### Added

- Add `git-hook` subcommand.

### Changed

- Update automation-client dependency.
Expand All @@ -16,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Deprecated

- The `git` and `gql-gen` subcommands have been moved to automation-client.
- Deprecate `githook` script in favor of `git-hook` subcommand.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion githook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ process.env.ATOMIST_DISABLE_LOGGING = "true";

import { runOnGitHook } from "@atomist/sdm-local";

// tslint:disable-next-line:no-floating-promises
process.stderr.write(`githook: [WARN] The githook script is deprecated. Use 'atomist git-hook'.`);
runOnGitHook(process.argv).catch(err => {
process.stderr.write(err.message + "\n");
process.exit(1);
Expand Down
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import * as yargs from "yargs";
import { config } from "./lib/config";
import { execute } from "./lib/execute";
import { git } from "./lib/git";
import { gitHook } from "./lib/gitHook";
import { gqlFetch } from "./lib/gqlFetch";
import { gqlGen } from "./lib/gqlGen";
import { kube } from "./lib/kube";
Expand Down Expand Up @@ -94,6 +95,9 @@ function setupYargs() {
}, argv => cliCommand(() => git({
cwd: argv["change-dir"],
})))
.command("git-hook", "Process Git hook data for local SDM", ya => {
return ya;
}, argv => cliCommand(() => gitHook(process.argv)))
.command("gql-fetch", "Retrieve GraphQL schema", (ya: yargs.Argv) => {
return ya
.option("change-dir", commonOptions.changeDir)
Expand Down
37 changes: 37 additions & 0 deletions lib/gitHook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright © 2018 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
runOnGitHook,
} from "@atomist/sdm-local";

import * as print from "./print";

/**
* Generate git-info.json for automation client.
*
* @param opts see GitOptions
* @return integer return value
*/
export async function gitHook(args: string[]): Promise<number> {
try {
await runOnGitHook(args);
} catch (e) {
print.error(`Failed to process Git hook: ${e.message}`);
return 1;
}
return 0;
}

0 comments on commit b226b91

Please sign in to comment.