Skip to content

Commit 7a1f208

Browse files
authored
Merge pull request #117 from rackerlabs/remove-ghe-info-from-visreg-task
fix(visreg): Ask for github username, not sso
2 parents 789302b + 8aa4050 commit 7a1f208

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

test/bin/util.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as opn from "opn"
1818
import {config, IConfig} from "./visreg.config";
1919

2020
export const f = "./.github-token";
21-
export const repoUrl = url.parse(`https://${config.githubHostname}/${config.githubName}/${config.repo}`);
21+
export const repoUrl = url.parse(`https://${config.githubHostname}/${config.githubUsername}/${config.repo}`);
2222
export const hasCommitRegex = /\[.*([0-9a-f]{7})] Checking in screenshots.../;
2323

2424
export function validateVPN(githubHostname: string) {
@@ -47,19 +47,11 @@ export async function checkConfig() {
4747
const updateTs = /name1234/.test(dataTs);
4848

4949
if (updateJs || updateTs) {
50-
const defaultUsername = "your sso";
5150
const options: IOptions = {
52-
default: defaultUsername,
53-
message: "Github Enterprise username?",
51+
message: "Github username?",
5452
};
5553

5654
const name = await input(options.message, options) as string;
57-
if (name === defaultUsername) {
58-
console.log(`Visit ${config.githubHostname} and log in to make sure this works.`);
59-
console.log("After logging in, copy the last part of the url on your homepage. It's likely your sso.");
60-
throw new Error("Please enter a valid Github Enterprise username.");
61-
}
62-
6355
const js = dataJs.replace(/name1234/, name);
6456
updateJs && fs.writeFileSync(javascriptConfig, js);
6557

@@ -152,7 +144,7 @@ export function createDiff(token: string, currentBranch: string, screenshotsDire
152144
}
153145

154146
export function pushBranch(token: string, repoUrl: url.Url, branch: string, screenshotsDirectory: string) {
155-
let pushUrl = `https://${token}@${repoUrl.hostname}/${config.githubName}/${config.repo}.git`;
147+
let pushUrl = `https://${token}@${repoUrl.hostname}/${config.githubUsername}/${config.repo}.git`;
156148
console.log(`Generating remote screenshot diff...`);
157149
safeExecSync(token, `cd ${screenshotsDirectory}; git push ${pushUrl} ${branch} > /dev/null 2>&1`);
158150
};
@@ -254,7 +246,7 @@ export function resetRepository(screenshotsDirectory: string) {
254246
if (fs.existsSync(`${screenshotsDirectory}/.git`)) {
255247
// check the current remote in case it's been updated
256248
const remote = child_process.execSync(`cd ${screenshotsDirectory}; git remote -v | head -n 1`).toString();
257-
const remoteRegex = new RegExp(`\bgit@${config.githubHostname}:${config.githubName}/${config.repo}.git\b`);
249+
const remoteRegex = new RegExp(`\bgit@${config.githubHostname}:${config.githubUsername}/${config.repo}.git\b`);
258250
if (!remoteRegex.test(remote)) {
259251
console.log("Updated screenshots repository detected -- cleaning.");
260252
cmd("npm run clean:screenshots");

test/bin/visreg.example.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
export interface IConfig {
66
githubHostname: string,
7-
githubName: string,
7+
githubUsername: string,
88
repo: string,
99
};
1010

@@ -16,7 +16,7 @@ export interface IConfig {
1616
* `visreg.config.ts` file.
1717
*/
1818
export var config: IConfig = {
19-
"githubHostname": "github.rackspace.com",
20-
"githubName": "name1234",
19+
"githubHostname": "github.com",
20+
"githubUsername": "name1234",
2121
"repo": "snappit-helix-ui",
2222
}

test/bin/visreg.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import * as opn from "opn";
77
import * as util from "./util";
88

99
import {config, IConfig} from "./visreg.config";
10-
const screenshotsDirectory = "visreg/screenshots";
11-
const repoUrl = url.parse(`https://${config.githubHostname}/${config.githubName}/${config.repo}`);
10+
const screenshotsDirectory = "artifacts/visregScreenshots";
11+
const repoUrl = url.parse(`https://${config.githubHostname}/${config.githubUsername}/${config.repo}`);
1212

1313
async function prepareRepository(token: string) {
1414
util.validateVPN(config.githubHostname);
@@ -34,7 +34,7 @@ async function visreg(
3434

3535
const anonymousBranch = `anon-${new Date().valueOf()}`;
3636
console.log("Creating a new baseline...");
37-
const baseCommit = util.createBaseline(token, anonymousBranch, screenshotsDirectory, targetBranch);
37+
const baseCommit = util.createBaseline(token, anonymousBranch, screenshotsDirectory, branch);
3838
console.log("Creating screenshot diff...");
3939
const afterCommit = util.createDiff(token, currentBranch, screenshotsDirectory);
4040
util.pushBranch(token, repoUrl, anonymousBranch, screenshotsDirectory);

test/types/inquirer-shortcuts.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface IOptions {
2-
default: String;
2+
default?: String;
33
message: String;
44
}
55

0 commit comments

Comments
 (0)