gh-manager-cli 1.10.2 → 1.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.10.4](https://github.com/wiiiimm/gh-manager-cli/compare/v1.10.3...v1.10.4) (2025-09-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * eliminate duplicate sync handler to prevent double execution ([bf838b6](https://github.com/wiiiimm/gh-manager-cli/commit/bf838b66f5c8b7def294d3835278cd32254bce1f))
7
+
8
+ ## [1.10.3](https://github.com/wiiiimm/gh-manager-cli/compare/v1.10.2...v1.10.3) (2025-09-01)
9
+
10
+
11
+ ### Performance Improvements
12
+
13
+ * optimize sync operation to update locally without API call ([b851c85](https://github.com/wiiiimm/gh-manager-cli/commit/b851c854a277b53f908e92d330622c4513642600))
14
+
1
15
  ## [1.10.2](https://github.com/wiiiimm/gh-manager-cli/compare/v1.10.1...v1.10.2) (2025-09-01)
2
16
 
3
17
 
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  __commonJS,
4
4
  archiveRepositoryById,
5
5
  deleteRepositoryRest,
6
- fetchRepositoryById,
7
6
  fetchViewerOrganizations,
8
7
  fetchViewerReposPageUnified,
9
8
  getRepositoryFromCache,
@@ -24,7 +23,7 @@ var require_package = __commonJS({
24
23
  "package.json"(exports, module) {
25
24
  module.exports = {
26
25
  name: "gh-manager-cli",
27
- version: "1.10.2",
26
+ version: "1.10.4",
28
27
  private: false,
29
28
  description: "Interactive CLI to manage your GitHub repos (personal) with Ink",
30
29
  license: "MIT",
@@ -487,6 +486,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
487
486
  const [syncing, setSyncing] = useState3(false);
488
487
  const [syncError, setSyncError] = useState3(null);
489
488
  const [syncFocus, setSyncFocus] = useState3("confirm");
489
+ const [syncTrigger, setSyncTrigger] = useState3(false);
490
490
  const [infoMode, setInfoMode] = useState3(false);
491
491
  const [infoRepo, setInfoRepo] = useState3(null);
492
492
  const [logoutMode, setLogoutMode] = useState3(false);
@@ -505,6 +505,46 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
505
505
  setSyncing(false);
506
506
  setSyncError(null);
507
507
  setSyncFocus("confirm");
508
+ setSyncTrigger(false);
509
+ }
510
+ async function executeSync() {
511
+ if (!syncTarget || syncing) return;
512
+ try {
513
+ setSyncing(true);
514
+ const [owner, repo] = syncTarget.nameWithOwner.split("/");
515
+ const branchName = syncTarget.defaultBranchRef?.name || "main";
516
+ const result = await syncForkWithUpstream(token, owner, repo, branchName);
517
+ const updatedRepo = {
518
+ ...syncTarget,
519
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
520
+ // If we're tracking fork commits and this is a fork with parent data, set commits to be in sync
521
+ ...forkTracking && syncTarget.isFork && syncTarget.parent && syncTarget.defaultBranchRef?.target?.history && syncTarget.parent.defaultBranchRef?.target?.history ? {
522
+ defaultBranchRef: {
523
+ ...syncTarget.defaultBranchRef,
524
+ target: {
525
+ ...syncTarget.defaultBranchRef.target,
526
+ history: {
527
+ // Set fork's commit count equal to parent's (0 commits behind)
528
+ totalCount: syncTarget.parent.defaultBranchRef.target.history.totalCount
529
+ }
530
+ }
531
+ }
532
+ } : {}
533
+ };
534
+ await updateCacheWithRepository(token, updatedRepo);
535
+ const updateSyncedRepo = (r) => {
536
+ if (r.id === syncTarget.id) {
537
+ return updatedRepo;
538
+ }
539
+ return r;
540
+ };
541
+ setItems((prev) => prev.map(updateSyncedRepo));
542
+ setSearchItems((prev) => prev.map(updateSyncedRepo));
543
+ closeSyncModal();
544
+ } catch (e) {
545
+ setSyncing(false);
546
+ setSyncError(e.message || "Failed to sync fork. Check permissions and network.");
547
+ }
508
548
  }
509
549
  function handleOrgContextChange(newContext) {
510
550
  setOwnerContext(newContext);
@@ -861,59 +901,17 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
861
901
  setSyncFocus("cancel");
862
902
  return;
863
903
  }
864
- if (key.return || input && input.toUpperCase() === "Y") {
904
+ if (input && input.toUpperCase() === "Y") {
865
905
  if (syncFocus === "cancel") {
866
906
  closeSyncModal();
867
- return;
907
+ } else {
908
+ executeSync();
868
909
  }
869
- if (!syncTarget) return;
870
- (async () => {
871
- try {
872
- setSyncing(true);
873
- const [owner, repo] = syncTarget.nameWithOwner.split("/");
874
- const branchName = syncTarget.defaultBranchRef?.name || "main";
875
- const result = await syncForkWithUpstream(token, owner, repo, branchName);
876
- const updatedRepo = await fetchRepositoryById(client, syncTarget.id, forkTracking);
877
- if (updatedRepo) {
878
- await updateCacheWithRepository(token, updatedRepo);
879
- const updateSyncedRepo = (r) => {
880
- if (r.id === syncTarget.id) {
881
- return updatedRepo;
882
- }
883
- return r;
884
- };
885
- setItems((prev) => prev.map(updateSyncedRepo));
886
- setSearchItems((prev) => prev.map(updateSyncedRepo));
887
- } else {
888
- const updateSyncedRepo = (r) => {
889
- if (r.id === syncTarget.id && r.parent && r.defaultBranchRef?.target?.history && r.parent.defaultBranchRef?.target?.history) {
890
- return {
891
- ...r,
892
- defaultBranchRef: {
893
- ...r.defaultBranchRef,
894
- target: {
895
- ...r.defaultBranchRef.target,
896
- history: {
897
- totalCount: r.parent.defaultBranchRef.target.history.totalCount
898
- }
899
- }
900
- }
901
- };
902
- }
903
- return r;
904
- };
905
- setItems((prev) => prev.map(updateSyncedRepo));
906
- setSearchItems((prev) => prev.map(updateSyncedRepo));
907
- }
908
- closeSyncModal();
909
- } catch (e) {
910
- setSyncing(false);
911
- setSyncError(e.message || "Failed to sync fork. Check permissions and network.");
912
- }
913
- })();
914
910
  return;
915
911
  }
916
- return;
912
+ if (!key.return) {
913
+ return;
914
+ }
917
915
  }
918
916
  if (logoutMode) {
919
917
  if (key.escape || input && input.toUpperCase() === "C") {
@@ -1510,50 +1508,7 @@ function RepoList({ token, maxVisibleRows, onLogout, viewerLogin, onOrgContextCh
1510
1508
  },
1511
1509
  onSubmit: () => {
1512
1510
  if (syncFocus === "confirm") {
1513
- (async () => {
1514
- try {
1515
- setSyncing(true);
1516
- const [owner, repo] = syncTarget.nameWithOwner.split("/");
1517
- const branchName = syncTarget.defaultBranchRef?.name || "main";
1518
- const result = await syncForkWithUpstream(token, owner, repo, branchName);
1519
- const updatedRepo = await fetchRepositoryById(client, syncTarget.id, forkTracking);
1520
- if (updatedRepo) {
1521
- await updateCacheWithRepository(token, updatedRepo);
1522
- const updateSyncedRepo = (r) => {
1523
- if (r.id === syncTarget.id) {
1524
- return updatedRepo;
1525
- }
1526
- return r;
1527
- };
1528
- setItems((prev) => prev.map(updateSyncedRepo));
1529
- setSearchItems((prev) => prev.map(updateSyncedRepo));
1530
- } else {
1531
- const updateSyncedRepo = (r) => {
1532
- if (r.id === syncTarget.id && r.parent && r.defaultBranchRef?.target?.history && r.parent.defaultBranchRef?.target?.history) {
1533
- return {
1534
- ...r,
1535
- defaultBranchRef: {
1536
- ...r.defaultBranchRef,
1537
- target: {
1538
- ...r.defaultBranchRef.target,
1539
- history: {
1540
- totalCount: r.parent.defaultBranchRef.target.history.totalCount
1541
- }
1542
- }
1543
- }
1544
- };
1545
- }
1546
- return r;
1547
- };
1548
- setItems((prev) => prev.map(updateSyncedRepo));
1549
- setSearchItems((prev) => prev.map(updateSyncedRepo));
1550
- }
1551
- closeSyncModal();
1552
- } catch (e) {
1553
- setSyncing(false);
1554
- setSyncError(e.message || "Failed to sync fork. Check permissions and network.");
1555
- }
1556
- })();
1511
+ executeSync();
1557
1512
  } else {
1558
1513
  closeSyncModal();
1559
1514
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gh-manager-cli",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "private": false,
5
5
  "description": "Interactive CLI to manage your GitHub repos (personal) with Ink",
6
6
  "license": "MIT",