Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ Create `.auth.json` in the directory you will run `bin/sync` from:
}
```

### GitHub Enterprise

To connect to a GHE you will need to add the GHE host to the `.auth.json` file above:

If no enterprise host is specified then the tool will default to `api.github.com`.

```
{
"username": "github-username",
"password": "github-auth-token",
"enterprise_host": "github.your-GHE-company.com"
}
```

## bin/sync.js

Synchronize labels and milestones across multiple products.
Expand Down
17 changes: 14 additions & 3 deletions lib/create-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,27 @@ auth.password = process.env.GH_PASSWORD || auth.password;
console.assert(auth.username || auth.token);
console.assert(auth.password || auth.token);

var github = new GitHubApi({
var github_params = {
// required
version: "3.0.0",
// optional
protocol: "https",
//timeout: 5000,

cachedb: '_cache.db',
validateCache: false,
});
}

ghe_host = auth.enterprise_host

if (ghe_host) {
console.info("Connecting to GitHub Enterprise (" + ghe_host + ")..")
github_params.host = ghe_host;
github_params.pathPrefix = "/api/v3"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the company specific URL and admins are actually free to use just about whatever root URL they like, so this is pretty specific to one company's GHE deployment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would I have the user specify the pathPrefix as well then?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the module being used.. seems they made the rather unfortunate choice of splitting the URL like this. I thought it was smarter than that :-(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I would do is make the config use a url and then parse it on load. Something like this maybe?

var ghUrl = require('url').parse(auth.url || 'https://api.github.com');
github_params.host = ghUrl.host;
github_params.pathPrefix = ghUrl.path;
console.info('Connecting to: %s', ghUrl.format());

} else {
console.info("Connecting to GitHub..")
}

var github = new GitHubApi(github_params);

if ('token' in auth) {
github.authenticate({
Expand Down