Skip to content

Commit

Permalink
fix: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Jul 17, 2023
1 parent dc0df13 commit 1125d9a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ inputs:
required: false
description: 'Branch to push report.'
default: 'workflows/weekly-stats'
SPECIFIC_REPO:
required: false
description: 'Specify the repo to stat.'

runs:
using: 'node16'
Expand Down
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,7 @@ var core = require_core();
var https = require("https");
var fs = require("fs");
var repo = process.env.GITHUB_REPOSITORY;
exec(`echo ${repo}`);
function getRange() {
const today = /* @__PURE__ */ new Date();
const lastWeek = new Date(
Expand Down Expand Up @@ -2239,6 +2240,9 @@ async function request(search) {
data += chunk;
});
res.on("end", () => {
console.log(url, JSON.parse(data));
exec(`echo ${url}`);
exec(`echo ${JSON.parse(data)}`);
resolve(JSON.parse(data));
});
}).on("error", reject);
Expand Down Expand Up @@ -2297,7 +2301,7 @@ async function getContributorIds() {
`commits?q=repo:${repo}+author-date:${since}..${until}`
);
const contributors = Array.from(
new Set(result.items.map((item) => item.author.login))
new Set(result?.items?.map((item) => item.author.login) || [])
);
return contributors.join(",") + ` (${contributors.length})`;
}
Expand Down
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
"@actions/core": "^1.10.0"
},
"devDependencies": {
"esbuild": "^0.18.13"
}
"esbuild": "^0.18.13",
"husky": "^8.0.3",
"lint-staged": "^13.2.3"
},
"husky": {
"hooks": {
"pre-commit": "npm run build && lint-staged"
}
},
"lint-staged": ""
}
3 changes: 3 additions & 0 deletions pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm run build
git add dist
exit 0
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const core = require('@actions/core');
const https = require('https');
const fs = require('fs');

const repo = process.env.GITHUB_REPOSITORY;
const repo = process.env.SPECIFIC_REPO || process.env.GITHUB_REPOSITORY;

console.log(repo);

/**
* get today and last week in format YYYY-MM-DD
Expand Down Expand Up @@ -50,6 +52,9 @@ async function request(search) {
data += chunk;
});
res.on('end', () => {
console.log(url, JSON.parse(data));
exec(`echo ${url}`);
exec(`echo ${JSON.parse(data)}`);
resolve(JSON.parse(data));
});
})
Expand Down Expand Up @@ -143,7 +148,7 @@ async function getContributorIds() {
`commits?q=repo:${repo}+author-date:${since}..${until}`
);
const contributors = Array.from(
new Set(result.items.map((item) => item.author.login))
new Set(result?.items?.map((item) => item.author.login) || [])
);
return contributors.join(',') + ` (${contributors.length})`;
}
Expand Down

0 comments on commit 1125d9a

Please sign in to comment.