mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-08 20:46:44 +03:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b604cad2fd | ||
|
|
983b47fa76 | ||
|
|
ea065d22a5 | ||
|
|
577d198e1a | ||
|
|
9ead32e9e6 | ||
|
|
993e7c1bc0 | ||
|
|
5b275a17e3 | ||
|
|
0caa327142 | ||
|
|
00d516a59d | ||
|
|
d68b822c76 | ||
|
|
b660d2dd9a | ||
|
|
4d8d75c8a6 | ||
|
|
e6c4ca0731 | ||
|
|
f03405b87a | ||
|
|
ce367e3761 | ||
|
|
cfe65cadca | ||
|
|
68108b8383 | ||
|
|
d2bec1d56e | ||
|
|
c9404f2674 | ||
|
|
80ef19c634 | ||
|
|
83c924566c | ||
|
|
7b58df375e | ||
|
|
1d27bd31d8 | ||
|
|
13d4257c4f | ||
|
|
818ba77693 | ||
|
|
056970e577 | ||
|
|
65ea73e238 |
82
CHANGELOG.md
82
CHANGELOG.md
@@ -7,6 +7,88 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [2.20.0] - 2025-07-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- **BREAKING**: Repository moved from `arunavo4/gitea-mirror` to `RayLabsHQ/gitea-mirror`
|
||||||
|
- Docker images now hosted at `ghcr.io/raylabshq/gitea-mirror`
|
||||||
|
- Updated all repository references and links to new organization
|
||||||
|
- License changed from MIT to GNU General Public License v3.0
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Updated GitHub API endpoint for version checking to use new repository location
|
||||||
|
- Corrected all documentation references to point to RayLabsHQ organization
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- Removed test security script after confirming vulnerability resolution
|
||||||
|
- Updated base Docker image to version 1.2.18-alpine
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
- Added repository migration notice in README
|
||||||
|
- Updated quickstart guide with new repository URLs
|
||||||
|
- Updated LXC deployment documentation with new repository location
|
||||||
|
|
||||||
|
## [2.18.0] - 2025-06-24
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Fourth organization strategy "Mixed Mode" that combines aspects of existing strategies
|
||||||
|
- Personal repositories go to a single configurable organization
|
||||||
|
- Organization repositories preserve their GitHub organization structure
|
||||||
|
- "Override Options" info button in Organization Strategy component explaining customization features
|
||||||
|
- Organization overrides via edit buttons on organization cards
|
||||||
|
- Repository overrides via inline destination editor
|
||||||
|
- Starred repositories behavior and priority hierarchy
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Simplified mixed strategy implementation to reuse existing database fields
|
||||||
|
- Enhanced organization strategy UI with comprehensive override documentation
|
||||||
|
- Better visual indicators for the new mixed strategy with orange color theme
|
||||||
|
|
||||||
|
## [2.17.0] - 2025-06-24
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Custom destination control for individual repositories with inline editing
|
||||||
|
- Organization-level destination overrides with visual destination editor
|
||||||
|
- Personal repositories organization override configuration option
|
||||||
|
- Visual indicators for starred repositories (⭐ icon) in repository list
|
||||||
|
- Repository-level destination override API endpoint
|
||||||
|
- Destination customization priority hierarchy system
|
||||||
|
- "View on Gitea" buttons for organizations with smart tooltip states
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Enhanced repository table with destination column showing both GitHub org and Gitea destination
|
||||||
|
- Updated organization cards to display custom destinations with visual indicators
|
||||||
|
- Improved getGiteaRepoOwnerAsync to support repository-level destination overrides
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Better visual feedback for custom destinations with badges and inline editing
|
||||||
|
- Enhanced user experience with hover-based edit buttons
|
||||||
|
- Comprehensive destination customization documentation in README
|
||||||
|
|
||||||
|
## [2.16.3] - 2025-06-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Custom 404 error page with helpful navigation links
|
||||||
|
- HoverCard components for better UX in configuration forms
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Replaced popover components with hover cards for information tooltips
|
||||||
|
- Enhanced user experience with responsive hover interactions
|
||||||
|
|
||||||
|
## [2.16.2] - 2025-06-17
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Bulk actions for repository management with selection support
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Enhanced organization card display with status badges and improved layout
|
||||||
|
|
||||||
|
## [2.16.1] - 2025-06-17
|
||||||
|
|
||||||
|
### Improved
|
||||||
|
- Improved repository owner handling and mirror strategy in Gitea integration
|
||||||
|
- Updated label for starred repositories organization for consistency
|
||||||
|
|
||||||
## [2.16.0] - 2025-06-17
|
## [2.16.0] - 2025-06-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export async function POST({ request }: APIContext) {
|
|||||||
- Uses Bun's native test runner (`bun:test`)
|
- Uses Bun's native test runner (`bun:test`)
|
||||||
- Test files use `.test.ts` or `.test.tsx` extension
|
- Test files use `.test.ts` or `.test.tsx` extension
|
||||||
- Setup file at `/src/tests/setup.bun.ts`
|
- Setup file at `/src/tests/setup.bun.ts`
|
||||||
- Mock utilities available for API testing
|
- Mock utilities available for API testing.
|
||||||
|
|
||||||
### Development Tips
|
### Development Tips
|
||||||
- Environment variables in `.env` (copy from `.env.example`)
|
- Environment variables in `.env` (copy from `.env.example`)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1.4
|
||||||
|
|
||||||
FROM oven/bun:1.2.16-alpine AS base
|
FROM oven/bun:1.2.18-alpine AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN apk add --no-cache libc6-compat python3 make g++ gcc wget sqlite openssl
|
RUN apk add --no-cache libc6-compat python3 make g++ gcc wget sqlite openssl
|
||||||
|
|
||||||
|
|||||||
632
LICENSE
632
LICENSE
@@ -1,21 +1,619 @@
|
|||||||
MIT License
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (c) 2025 ARUNAVO RAY
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Preamble
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
copies or substantial portions of the Software.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The licenses for most software and other practical works are designed
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
share and change all versions of a program--to make sure it remains free
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
software for all its users.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|||||||
72
README.md
72
README.md
@@ -3,13 +3,23 @@
|
|||||||
<h1>Gitea Mirror</h1>
|
<h1>Gitea Mirror</h1>
|
||||||
<p><i>A modern web app for automatically mirroring repositories from GitHub to your self-hosted Gitea.</i></p>
|
<p><i>A modern web app for automatically mirroring repositories from GitHub to your self-hosted Gitea.</i></p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/arunavo4/gitea-mirror/releases/latest"><img src="https://img.shields.io/github/v/tag/arunavo4/gitea-mirror?label=release" alt="release"/></a>
|
<a href="https://github.com/RayLabsHQ/gitea-mirror/releases/latest"><img src="https://img.shields.io/github/v/tag/RayLabsHQ/gitea-mirror?label=release" alt="release"/></a>
|
||||||
<a href="https://github.com/arunavo4/gitea-mirror/actions/workflows/astro-build-test.yml"><img src="https://img.shields.io/github/actions/workflow/status/arunavo4/gitea-mirror/astro-build-test.yml?branch=main" alt="build"/></a>
|
<a href="https://github.com/RayLabsHQ/gitea-mirror/actions/workflows/astro-build-test.yml"><img src="https://img.shields.io/github/actions/workflow/status/RayLabsHQ/gitea-mirror/astro-build-test.yml?branch=main" alt="build"/></a>
|
||||||
<a href="https://github.com/arunavo4/gitea-mirror/pkgs/container/gitea-mirror"><img src="https://img.shields.io/badge/ghcr.io-container-blue?logo=github" alt="container"/></a>
|
<a href="https://github.com/RayLabsHQ/gitea-mirror/pkgs/container/gitea-mirror"><img src="https://img.shields.io/badge/ghcr.io-container-blue?logo=github" alt="container"/></a>
|
||||||
<a href="https://github.com/arunavo4/gitea-mirror/blob/main/LICENSE"><img src="https://img.shields.io/github/license/arunavo4/gitea-mirror" alt="license"/></a>
|
<a href="https://github.com/RayLabsHQ/gitea-mirror/blob/main/LICENSE"><img src="https://img.shields.io/github/license/RayLabsHQ/gitea-mirror" alt="license"/></a>
|
||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> **Repository Migration Notice**: Starting from version 2.20, this project has moved from `arunavo4/gitea-mirror` to `RayLabsHQ/gitea-mirror`. Please update your Docker images and Git remotes to use the new location:
|
||||||
|
> ```bash
|
||||||
|
> # Docker
|
||||||
|
> docker pull ghcr.io/raylabshq/gitea-mirror:latest
|
||||||
|
>
|
||||||
|
> # Git remote
|
||||||
|
> git remote set-url origin https://github.com/RayLabsHQ/gitea-mirror.git
|
||||||
|
> ```
|
||||||
|
|
||||||
## 🚀 Quick Start
|
## 🚀 Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -37,6 +47,7 @@ See the [LXC Container Deployment Guide](scripts/README-lxc.md).
|
|||||||
|
|
||||||
- 🔁 Sync public, private, or starred GitHub repos to Gitea
|
- 🔁 Sync public, private, or starred GitHub repos to Gitea
|
||||||
- 🏢 Mirror entire organizations with flexible organization strategies
|
- 🏢 Mirror entire organizations with flexible organization strategies
|
||||||
|
- 🎯 Custom destination control for both organizations and individual repositories
|
||||||
- 🐞 Optional mirroring of issues and labels
|
- 🐞 Optional mirroring of issues and labels
|
||||||
- 🌟 Mirror your starred repositories to a dedicated organization
|
- 🌟 Mirror your starred repositories to a dedicated organization
|
||||||
- 🕹️ Modern user interface with toast notifications and smooth experience
|
- 🕹️ Modern user interface with toast notifications and smooth experience
|
||||||
@@ -136,12 +147,12 @@ If you want to run the container directly without Docker Compose:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull the latest multi-architecture image
|
# Pull the latest multi-architecture image
|
||||||
docker pull ghcr.io/arunavo4/gitea-mirror:latest
|
docker pull ghcr.io/RayLabsHQ/gitea-mirror:latest
|
||||||
|
|
||||||
# Run the application with a volume for persistent data
|
# Run the application with a volume for persistent data
|
||||||
docker run -d -p 4321:4321 \
|
docker run -d -p 4321:4321 \
|
||||||
-v gitea-mirror-data:/app/data \
|
-v gitea-mirror-data:/app/data \
|
||||||
ghcr.io/arunavo4/gitea-mirror:latest
|
ghcr.io/RayLabsHQ/gitea-mirror:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Building Docker Images Manually
|
##### Building Docker Images Manually
|
||||||
@@ -233,7 +244,7 @@ The Docker container can be configured with the following environment variables:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Clone the repository
|
# Clone the repository
|
||||||
git clone https://github.com/arunavo4/gitea-mirror.git
|
git clone https://github.com/RayLabsHQ/gitea-mirror.git
|
||||||
cd gitea-mirror
|
cd gitea-mirror
|
||||||
|
|
||||||
# Quick setup (installs dependencies and initializes the database)
|
# Quick setup (installs dependencies and initializes the database)
|
||||||
@@ -317,14 +328,14 @@ Key configuration options include:
|
|||||||
> [!IMPORTANT]
|
> [!IMPORTANT]
|
||||||
> **SQLite is the only database required for Gitea Mirror**, handling both data storage and real-time event notifications.
|
> **SQLite is the only database required for Gitea Mirror**, handling both data storage and real-time event notifications.
|
||||||
|
|
||||||
### Mirror Strategies
|
### Mirror Strategies & Destination Customization
|
||||||
|
|
||||||
Gitea Mirror offers three flexible strategies for organizing your repositories in Gitea:
|
Gitea Mirror offers three flexible strategies for organizing your repositories in Gitea, with fine-grained control over destinations:
|
||||||
|
|
||||||
#### 1. **Preserve GitHub Structure** (Default)
|
#### 1. **Preserve GitHub Structure** (Default)
|
||||||
- Personal repositories → Your Gitea username
|
- Personal repositories → Your Gitea username (or custom organization)
|
||||||
- Organization repositories → Same organization name in Gitea
|
- Organization repositories → Same organization name in Gitea (with individual overrides)
|
||||||
- Maintains the exact structure from GitHub
|
- Maintains the exact structure from GitHub with optional customization
|
||||||
|
|
||||||
#### 2. **Single Organization**
|
#### 2. **Single Organization**
|
||||||
- All repositories → One designated organization
|
- All repositories → One designated organization
|
||||||
@@ -336,8 +347,37 @@ Gitea Mirror offers three flexible strategies for organizing your repositories i
|
|||||||
- No organizations needed
|
- No organizations needed
|
||||||
- Simplest approach for personal use
|
- Simplest approach for personal use
|
||||||
|
|
||||||
|
#### Destination Customization
|
||||||
|
|
||||||
|
**Organization-Level Overrides:**
|
||||||
|
- Click the edit button on any organization card to set a custom destination
|
||||||
|
- All repositories from that GitHub organization will be mirrored to your specified Gitea organization
|
||||||
|
- Visual indicators show when custom destinations are active
|
||||||
|
|
||||||
|
**Repository-Level Overrides:**
|
||||||
|
- Fine-tune individual repository destinations in the repository table
|
||||||
|
- Click the edit button in the "Destination" column to customize where a specific repo is mirrored
|
||||||
|
- Overrides organization-level settings for maximum flexibility
|
||||||
|
- Starred repositories display a ⭐ icon and always go to the configured starred repos organization
|
||||||
|
|
||||||
|
**Priority Hierarchy:**
|
||||||
|
1. Starred repositories → Always go to `starredReposOrg` (not editable)
|
||||||
|
2. Repository-level custom destination (highest priority for non-starred)
|
||||||
|
3. Organization-level custom destination
|
||||||
|
4. Personal repos override (for non-organization repos)
|
||||||
|
5. Default strategy rules (lowest priority)
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> **Starred Repositories**: Regardless of the chosen strategy, starred repositories are always mirrored to a separate organization (default: "starred") to keep them organized separately from your own repositories.
|
> **Starred Repositories**: Repositories you've starred on GitHub are automatically organized into a separate organization (default: "starred") and cannot have custom destinations. They're marked with a ⭐ icon for easy identification.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> **Example Use Cases**:
|
||||||
|
> - Mirror personal repos to `personal-archive` organization
|
||||||
|
> - Redirect `work-org` repos to `company-mirror` in Gitea
|
||||||
|
> - Override a single important repo to go to a special organization
|
||||||
|
> - Keep `company-org` repos in their own `company-org` organization
|
||||||
|
> - Override `community-scripts` to go to `community-mirrors` organization
|
||||||
|
> - This gives you complete control while maintaining GitHub's structure as the default
|
||||||
|
|
||||||
## 🚀 Development
|
## 🚀 Development
|
||||||
|
|
||||||
@@ -409,7 +449,7 @@ docker run -d \
|
|||||||
-e GITEA_URL=http://gitea:3000 \
|
-e GITEA_URL=http://gitea:3000 \
|
||||||
-e GITEA_TOKEN=your-local-gitea-token \
|
-e GITEA_TOKEN=your-local-gitea-token \
|
||||||
-e GITEA_USERNAME=your-local-gitea-username \
|
-e GITEA_USERNAME=your-local-gitea-username \
|
||||||
arunavo4/gitea-mirror:latest
|
RayLabsHQ/gitea-mirror:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
@@ -510,14 +550,14 @@ Try the following steps:
|
|||||||
> # Run with a volume for persistent data storage
|
> # Run with a volume for persistent data storage
|
||||||
> docker run -d -p 4321:4321 \
|
> docker run -d -p 4321:4321 \
|
||||||
> -v gitea-mirror-data:/app/data \
|
> -v gitea-mirror-data:/app/data \
|
||||||
> ghcr.io/arunavo4/gitea-mirror:latest
|
> ghcr.io/RayLabsHQ/gitea-mirror:latest
|
||||||
> ```
|
> ```
|
||||||
>
|
>
|
||||||
> For homelab/self-hosted setups, you can use the standard Docker Compose file which includes automatic database cleanup:
|
> For homelab/self-hosted setups, you can use the standard Docker Compose file which includes automatic database cleanup:
|
||||||
>
|
>
|
||||||
> ```bash
|
> ```bash
|
||||||
> # Clone the repository
|
> # Clone the repository
|
||||||
> git clone https://github.com/arunavo4/gitea-mirror.git
|
> git clone https://github.com/RayLabsHQ/gitea-mirror.git
|
||||||
> cd gitea-mirror
|
> cd gitea-mirror
|
||||||
>
|
>
|
||||||
> # Start the application with Docker Compose
|
> # Start the application with Docker Compose
|
||||||
|
|||||||
3
bun.lock
3
bun.lock
@@ -15,6 +15,7 @@
|
|||||||
"@radix-ui/react-collapsible": "^1.1.11",
|
"@radix-ui/react-collapsible": "^1.1.11",
|
||||||
"@radix-ui/react-dialog": "^1.1.14",
|
"@radix-ui/react-dialog": "^1.1.14",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||||
|
"@radix-ui/react-hover-card": "^1.1.14",
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@radix-ui/react-popover": "^1.1.14",
|
"@radix-ui/react-popover": "^1.1.14",
|
||||||
"@radix-ui/react-radio-group": "^1.3.7",
|
"@radix-ui/react-radio-group": "^1.3.7",
|
||||||
@@ -334,6 +335,8 @@
|
|||||||
|
|
||||||
"@radix-ui/react-focus-scope": ["@radix-ui/react-focus-scope@1.1.7", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-t2ODlkXBQyn7jkl6TNaw/MtVEVvIGelJDCG41Okq/KwUsJBwQ4XVZsHAVUkK4mBv3ewiAS3PGuUWuY2BoK4ZUw=="],
|
"@radix-ui/react-focus-scope": ["@radix-ui/react-focus-scope@1.1.7", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-callback-ref": "1.1.1" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-t2ODlkXBQyn7jkl6TNaw/MtVEVvIGelJDCG41Okq/KwUsJBwQ4XVZsHAVUkK4mBv3ewiAS3PGuUWuY2BoK4ZUw=="],
|
||||||
|
|
||||||
|
"@radix-ui/react-hover-card": ["@radix-ui/react-hover-card@1.1.14", "", { "dependencies": { "@radix-ui/primitive": "1.1.2", "@radix-ui/react-compose-refs": "1.1.2", "@radix-ui/react-context": "1.1.2", "@radix-ui/react-dismissable-layer": "1.1.10", "@radix-ui/react-popper": "1.2.7", "@radix-ui/react-portal": "1.1.9", "@radix-ui/react-presence": "1.1.4", "@radix-ui/react-primitive": "2.1.3", "@radix-ui/react-use-controllable-state": "1.2.2" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-CPYZ24Mhirm+g6D8jArmLzjYu4Eyg3TTUHswR26QgzXBHBe64BO/RHOJKzmF/Dxb4y4f9PKyJdwm/O/AhNkb+Q=="],
|
||||||
|
|
||||||
"@radix-ui/react-id": ["@radix-ui/react-id@1.1.1", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg=="],
|
"@radix-ui/react-id": ["@radix-ui/react-id@1.1.1", "", { "dependencies": { "@radix-ui/react-use-layout-effect": "1.1.1" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg=="],
|
||||||
|
|
||||||
"@radix-ui/react-label": ["@radix-ui/react-label@2.1.7", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-YT1GqPSL8kJn20djelMX7/cTRp/Y9w5IZHvfxQTVHrOqa2yMl7i/UfMqKRU5V7mEyKTrUVgJXhNQPVCG8PBLoQ=="],
|
"@radix-ui/react-label": ["@radix-ui/react-label@2.1.7", "", { "dependencies": { "@radix-ui/react-primitive": "2.1.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-YT1GqPSL8kJn20djelMX7/cTRp/Y9w5IZHvfxQTVHrOqa2yMl7i/UfMqKRU5V7mEyKTrUVgJXhNQPVCG8PBLoQ=="],
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
gitea-mirror:
|
gitea-mirror:
|
||||||
image: ${DOCKER_REGISTRY:-ghcr.io}/${DOCKER_IMAGE:-arunavo4/gitea-mirror}:${DOCKER_TAG:-latest}
|
image: ${DOCKER_REGISTRY:-ghcr.io}/${DOCKER_IMAGE:-raylabshq/gitea-mirror}:${DOCKER_TAG:-latest}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
@@ -11,7 +11,7 @@ services:
|
|||||||
- linux/amd64
|
- linux/amd64
|
||||||
- linux/arm64
|
- linux/arm64
|
||||||
cache_from:
|
cache_from:
|
||||||
- ${DOCKER_REGISTRY:-ghcr.io}/${DOCKER_IMAGE:-arunavo4/gitea-mirror}:${DOCKER_TAG:-latest}
|
- ${DOCKER_REGISTRY:-ghcr.io}/${DOCKER_IMAGE:-raylabshq/gitea-mirror}:${DOCKER_TAG:-latest}
|
||||||
container_name: gitea-mirror
|
container_name: gitea-mirror
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-mirror",
|
"name": "gitea-mirror",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.16.0",
|
"version": "2.20.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"bun": ">=1.2.9"
|
"bun": ">=1.2.9"
|
||||||
},
|
},
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
"@radix-ui/react-collapsible": "^1.1.11",
|
"@radix-ui/react-collapsible": "^1.1.11",
|
||||||
"@radix-ui/react-dialog": "^1.1.14",
|
"@radix-ui/react-dialog": "^1.1.14",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
||||||
|
"@radix-ui/react-hover-card": "^1.1.14",
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@radix-ui/react-popover": "^1.1.14",
|
"@radix-ui/react-popover": "^1.1.14",
|
||||||
"@radix-ui/react-radio-group": "^1.3.7",
|
"@radix-ui/react-radio-group": "^1.3.7",
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ http://<container-ip>:4321
|
|||||||
### Offline installer script
|
### Offline installer script
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/arunavo4/gitea-mirror.git # if not already
|
git clone https://github.com/RayLabsHQ/gitea-mirror.git # if not already
|
||||||
curl -fsSL https://raw.githubusercontent.com/arunavo4/gitea-mirror/main/scripts/gitea-mirror-lxc-local.sh -o gitea-mirror-lxc-local.sh
|
curl -fsSL https://raw.githubusercontent.com/arunavo4/gitea-mirror/main/scripts/gitea-mirror-lxc-local.sh -o gitea-mirror-lxc-local.sh
|
||||||
chmod +x gitea-mirror-lxc-local.sh
|
chmod +x gitea-mirror-lxc-local.sh
|
||||||
|
|
||||||
|
|||||||
81
src/components/NotFound.tsx
Normal file
81
src/components/NotFound.tsx
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||||
|
import { Home, ArrowLeft, GitBranch, BookOpen, Settings, FileQuestion } from "lucide-react";
|
||||||
|
|
||||||
|
export function NotFound() {
|
||||||
|
return (
|
||||||
|
<div className="h-dvh bg-muted/30 flex items-center justify-center p-4">
|
||||||
|
<Card className="w-full max-w-md">
|
||||||
|
<CardHeader className="text-center pb-4">
|
||||||
|
<div className="mx-auto mb-4 h-16 w-16 rounded-full bg-muted flex items-center justify-center">
|
||||||
|
<FileQuestion className="h-8 w-8 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<h1 className="text-3xl font-bold">404</h1>
|
||||||
|
<h2 className="text-xl font-semibold mt-2">Page Not Found</h2>
|
||||||
|
<p className="text-muted-foreground mt-2">
|
||||||
|
The page you're looking for doesn't exist or has been moved.
|
||||||
|
</p>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent className="space-y-6">
|
||||||
|
{/* Action Buttons */}
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
<Button asChild className="w-full">
|
||||||
|
<a href="/">
|
||||||
|
<Home className="mr-2 h-4 w-4" />
|
||||||
|
Go to Dashboard
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" className="w-full" onClick={() => window.history.back()}>
|
||||||
|
<ArrowLeft className="mr-2 h-4 w-4" />
|
||||||
|
Go Back
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Divider */}
|
||||||
|
<div className="relative">
|
||||||
|
<div className="absolute inset-0 flex items-center">
|
||||||
|
<span className="w-full border-t" />
|
||||||
|
</div>
|
||||||
|
<div className="relative flex justify-center text-xs uppercase">
|
||||||
|
<span className="bg-card px-2 text-muted-foreground">or visit</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Quick Links */}
|
||||||
|
<div className="grid grid-cols-3 gap-3">
|
||||||
|
<a
|
||||||
|
href="/repositories"
|
||||||
|
className="flex flex-col items-center gap-2 p-3 rounded-md hover:bg-muted transition-colors"
|
||||||
|
>
|
||||||
|
<GitBranch className="h-5 w-5 text-muted-foreground" />
|
||||||
|
<span className="text-xs">Repositories</span>
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
href="/config"
|
||||||
|
className="flex flex-col items-center gap-2 p-3 rounded-md hover:bg-muted transition-colors"
|
||||||
|
>
|
||||||
|
<Settings className="h-5 w-5 text-muted-foreground" />
|
||||||
|
<span className="text-xs">Config</span>
|
||||||
|
</a>
|
||||||
|
<a
|
||||||
|
href="/docs"
|
||||||
|
className="flex flex-col items-center gap-2 p-3 rounded-md hover:bg-muted transition-colors"
|
||||||
|
>
|
||||||
|
<BookOpen className="h-5 w-5 text-muted-foreground" />
|
||||||
|
<span className="text-xs">Docs</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Code */}
|
||||||
|
<div className="text-center pt-2">
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Error Code: <code className="font-mono">404_NOT_FOUND</code>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -97,6 +97,11 @@ export function ConfigTabs() {
|
|||||||
return isGitHubValid && isGiteaValid;
|
return isGitHubValid && isGiteaValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isGitHubConfigValid = (): boolean => {
|
||||||
|
const { githubConfig } = config;
|
||||||
|
return !!(githubConfig.username.trim() && githubConfig.token.trim());
|
||||||
|
};
|
||||||
|
|
||||||
// Removed the problematic useEffect that was causing circular dependencies
|
// Removed the problematic useEffect that was causing circular dependencies
|
||||||
// The lastRun and nextRun should be managed by the backend and fetched via API
|
// The lastRun and nextRun should be managed by the backend and fetched via API
|
||||||
|
|
||||||
@@ -571,10 +576,10 @@ export function ConfigTabs() {
|
|||||||
<div className="flex gap-x-4">
|
<div className="flex gap-x-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={handleImportGitHubData}
|
onClick={handleImportGitHubData}
|
||||||
disabled={isSyncing || !isConfigFormValid()}
|
disabled={isSyncing || !isGitHubConfigValid()}
|
||||||
title={
|
title={
|
||||||
!isConfigFormValid()
|
!isGitHubConfigValid()
|
||||||
? 'Please fill all required GitHub and Gitea fields'
|
? 'Please fill GitHub username and token fields'
|
||||||
: isSyncing
|
: isSyncing
|
||||||
? 'Import in progress'
|
? 'Import in progress'
|
||||||
: 'Import GitHub Data'
|
: 'Import GitHub Data'
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import { Info } from "lucide-react";
|
|||||||
import { GitHubMirrorSettings } from "./GitHubMirrorSettings";
|
import { GitHubMirrorSettings } from "./GitHubMirrorSettings";
|
||||||
import { Separator } from "../ui/separator";
|
import { Separator } from "../ui/separator";
|
||||||
import {
|
import {
|
||||||
Popover,
|
HoverCard,
|
||||||
PopoverContent,
|
HoverCardContent,
|
||||||
PopoverTrigger,
|
HoverCardTrigger,
|
||||||
} from "@/components/ui/popover";
|
} from "@/components/ui/hover-card";
|
||||||
|
|
||||||
interface GitHubConfigFormProps {
|
interface GitHubConfigFormProps {
|
||||||
config: GitHubConfig;
|
config: GitHubConfig;
|
||||||
@@ -130,16 +130,13 @@ export function GitHubConfigForm({
|
|||||||
>
|
>
|
||||||
GitHub Token
|
GitHub Token
|
||||||
</label>
|
</label>
|
||||||
<Popover>
|
<HoverCard openDelay={200}>
|
||||||
<PopoverTrigger asChild>
|
<HoverCardTrigger asChild>
|
||||||
<button
|
<span className="inline-flex p-0.5 hover:bg-muted rounded-sm transition-colors cursor-help">
|
||||||
type="button"
|
|
||||||
className="p-0.5 hover:bg-muted rounded-sm transition-colors"
|
|
||||||
>
|
|
||||||
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
</button>
|
</span>
|
||||||
</PopoverTrigger>
|
</HoverCardTrigger>
|
||||||
<PopoverContent side="right" align="start" className="w-80">
|
<HoverCardContent side="right" align="start" className="w-80">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h4 className="font-medium text-sm">GitHub Token Requirements</h4>
|
<h4 className="font-medium text-sm">GitHub Token Requirements</h4>
|
||||||
<div className="text-sm space-y-2">
|
<div className="text-sm space-y-2">
|
||||||
@@ -166,8 +163,8 @@ export function GitHubConfigForm({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</HoverCardContent>
|
||||||
</Popover>
|
</HoverCard>
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
id="github-token"
|
id="github-token"
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g
|
|||||||
strategy={mirrorStrategy}
|
strategy={mirrorStrategy}
|
||||||
destinationOrg={config.organization}
|
destinationOrg={config.organization}
|
||||||
starredReposOrg={config.starredReposOrg}
|
starredReposOrg={config.starredReposOrg}
|
||||||
|
personalReposOrg={config.personalReposOrg}
|
||||||
visibility={config.visibility}
|
visibility={config.visibility}
|
||||||
onDestinationOrgChange={(org) => {
|
onDestinationOrgChange={(org) => {
|
||||||
const newConfig = { ...config, organization: org };
|
const newConfig = { ...config, organization: org };
|
||||||
@@ -228,6 +229,11 @@ export function GiteaConfigForm({ config, setConfig, onAutoSave, isAutoSaving, g
|
|||||||
setConfig(newConfig);
|
setConfig(newConfig);
|
||||||
if (onAutoSave) onAutoSave(newConfig);
|
if (onAutoSave) onAutoSave(newConfig);
|
||||||
}}
|
}}
|
||||||
|
onPersonalReposOrgChange={(org) => {
|
||||||
|
const newConfig = { ...config, personalReposOrg: org };
|
||||||
|
setConfig(newConfig);
|
||||||
|
if (onAutoSave) onAutoSave(newConfig);
|
||||||
|
}}
|
||||||
onVisibilityChange={(visibility) => {
|
onVisibilityChange={(visibility) => {
|
||||||
const newConfig = { ...config, visibility };
|
const newConfig = { ...config, visibility };
|
||||||
setConfig(newConfig);
|
setConfig(newConfig);
|
||||||
|
|||||||
@@ -15,9 +15,11 @@ interface OrganizationConfigurationProps {
|
|||||||
strategy: MirrorStrategy;
|
strategy: MirrorStrategy;
|
||||||
destinationOrg?: string;
|
destinationOrg?: string;
|
||||||
starredReposOrg?: string;
|
starredReposOrg?: string;
|
||||||
|
personalReposOrg?: string;
|
||||||
visibility: GiteaOrgVisibility;
|
visibility: GiteaOrgVisibility;
|
||||||
onDestinationOrgChange: (org: string) => void;
|
onDestinationOrgChange: (org: string) => void;
|
||||||
onStarredReposOrgChange: (org: string) => void;
|
onStarredReposOrgChange: (org: string) => void;
|
||||||
|
onPersonalReposOrgChange: (org: string) => void;
|
||||||
onVisibilityChange: (visibility: GiteaOrgVisibility) => void;
|
onVisibilityChange: (visibility: GiteaOrgVisibility) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,9 +33,11 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
|
|||||||
strategy,
|
strategy,
|
||||||
destinationOrg,
|
destinationOrg,
|
||||||
starredReposOrg,
|
starredReposOrg,
|
||||||
|
personalReposOrg,
|
||||||
visibility,
|
visibility,
|
||||||
onDestinationOrgChange,
|
onDestinationOrgChange,
|
||||||
onStarredReposOrgChange,
|
onStarredReposOrgChange,
|
||||||
|
onPersonalReposOrgChange,
|
||||||
onVisibilityChange,
|
onVisibilityChange,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
@@ -51,7 +55,7 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
|
|||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label htmlFor="starredReposOrg" className="text-sm font-normal flex items-center gap-2">
|
<Label htmlFor="starredReposOrg" className="text-sm font-normal flex items-center gap-2">
|
||||||
<Star className="h-3.5 w-3.5" />
|
<Star className="h-3.5 w-3.5" />
|
||||||
Starred Repositories Organization
|
Starred Repos Organization
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
@@ -75,18 +79,23 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Right column - shows destination org for single-org, empty div for others */}
|
{/* Right column - shows destination org for single-org/mixed, personal repos org for preserve, empty div for others */}
|
||||||
{strategy === "single-org" ? (
|
{strategy === "single-org" || strategy === "mixed" ? (
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label htmlFor="destinationOrg" className="text-sm font-normal flex items-center gap-2">
|
<Label htmlFor="destinationOrg" className="text-sm font-normal flex items-center gap-2">
|
||||||
Destination Organization
|
{strategy === "mixed" ? "Personal Repos Organization" : "Destination Organization"}
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<TooltipTrigger>
|
<TooltipTrigger>
|
||||||
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
<p>All repositories will be mirrored to this organization</p>
|
<p>
|
||||||
|
{strategy === "mixed"
|
||||||
|
? "Personal repositories will be mirrored to this organization, while organization repos preserve their structure"
|
||||||
|
: "All repositories will be mirrored to this organization"
|
||||||
|
}
|
||||||
|
</p>
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
@@ -99,11 +108,40 @@ export const OrganizationConfiguration: React.FC<OrganizationConfigurationProps>
|
|||||||
className=""
|
className=""
|
||||||
/>
|
/>
|
||||||
<p className="text-xs text-muted-foreground mt-1">
|
<p className="text-xs text-muted-foreground mt-1">
|
||||||
Organization for consolidated repositories
|
{strategy === "mixed"
|
||||||
|
? "All personal repos will go to this organization"
|
||||||
|
: "Organization for consolidated repositories"
|
||||||
|
}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : strategy === "preserve" ? (
|
||||||
|
<div className="space-y-1">
|
||||||
|
<Label htmlFor="personalReposOrg" className="text-sm font-normal flex items-center gap-2">
|
||||||
|
Personal Repos Organization
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger>
|
||||||
|
<Info className="h-3.5 w-3.5 text-muted-foreground" />
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Override where your personal repositories are mirrored (leave empty to use your username)</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="personalReposOrg"
|
||||||
|
value={personalReposOrg || ""}
|
||||||
|
onChange={(e) => onPersonalReposOrgChange(e.target.value)}
|
||||||
|
placeholder="my-personal-mirrors"
|
||||||
|
className=""
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground mt-1">
|
||||||
|
Override destination for your personal repos
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="hidden md:block" />
|
<div className="hidden md:block" />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import { Card } from "@/components/ui/card";
|
|||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
import { Info, GitBranch, FolderTree, Star, Building2, User, Building } from "lucide-react";
|
import { Info, GitBranch, FolderTree, Star, Building2, User, Building } from "lucide-react";
|
||||||
import {
|
import {
|
||||||
Popover,
|
HoverCard,
|
||||||
PopoverContent,
|
HoverCardContent,
|
||||||
PopoverTrigger,
|
HoverCardTrigger,
|
||||||
} from "@/components/ui/popover";
|
} from "@/components/ui/hover-card";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
export type MirrorStrategy = "preserve" | "single-org" | "flat-user";
|
export type MirrorStrategy = "preserve" | "single-org" | "flat-user" | "mixed";
|
||||||
|
|
||||||
interface OrganizationStrategyProps {
|
interface OrganizationStrategyProps {
|
||||||
strategy: MirrorStrategy;
|
strategy: MirrorStrategy;
|
||||||
@@ -56,6 +56,18 @@ const strategyConfig = {
|
|||||||
bg: "bg-green-50 dark:bg-green-950/30",
|
bg: "bg-green-50 dark:bg-green-950/30",
|
||||||
icon: "text-green-600 dark:text-green-400"
|
icon: "text-green-600 dark:text-green-400"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"mixed": {
|
||||||
|
title: "Mixed Mode",
|
||||||
|
icon: GitBranch,
|
||||||
|
description: "user repos in single org, org repos preserve structure",
|
||||||
|
color: "text-orange-600 dark:text-orange-400",
|
||||||
|
bgColor: "bg-orange-50 dark:bg-orange-950/20",
|
||||||
|
borderColor: "border-orange-200 dark:border-orange-900",
|
||||||
|
repoColors: {
|
||||||
|
bg: "bg-orange-50 dark:bg-orange-950/30",
|
||||||
|
icon: "text-orange-600 dark:text-orange-400"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,6 +221,52 @@ const MappingPreview: React.FC<{
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strategy === "mixed") {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-between gap-6">
|
||||||
|
<div className="flex-1">
|
||||||
|
<div className="text-xs font-medium text-muted-foreground mb-2">GitHub</div>
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<div className="flex items-center gap-2 p-1.5 bg-gray-50 dark:bg-gray-800 rounded text-xs">
|
||||||
|
<User className="h-3 w-3" />
|
||||||
|
<span className={cn(isGithubPlaceholder && "text-muted-foreground italic")}>{displayGithubUsername}/my-repo</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 p-1.5 bg-gray-50 dark:bg-gray-800 rounded text-xs">
|
||||||
|
<Building2 className="h-3 w-3" />
|
||||||
|
<span>my-org/team-repo</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2 p-1.5 bg-gray-50 dark:bg-gray-800 rounded text-xs">
|
||||||
|
<Star className="h-3 w-3" />
|
||||||
|
<span>awesome/starred-repo</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center">
|
||||||
|
<GitBranch className="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex-1">
|
||||||
|
<div className="text-xs font-medium text-muted-foreground mb-2">Gitea</div>
|
||||||
|
<div className="space-y-1.5">
|
||||||
|
<div className={cn("flex items-center gap-2 p-1.5 rounded text-xs", config.repoColors.bg)}>
|
||||||
|
<Building2 className={cn("h-3 w-3", config.repoColors.icon)} />
|
||||||
|
<span>{destinationOrg || "github-mirrors"}/my-repo</span>
|
||||||
|
</div>
|
||||||
|
<div className={cn("flex items-center gap-2 p-1.5 rounded text-xs", config.repoColors.bg)}>
|
||||||
|
<Building2 className={cn("h-3 w-3", config.repoColors.icon)} />
|
||||||
|
<span>my-org/team-repo</span>
|
||||||
|
</div>
|
||||||
|
<div className={cn("flex items-center gap-2 p-1.5 rounded text-xs", config.repoColors.bg)}>
|
||||||
|
<Building2 className={cn("h-3 w-3", config.repoColors.icon)} />
|
||||||
|
<span>{starredReposOrg || "starred"}/starred-repo</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -223,14 +281,78 @@ export const OrganizationStrategy: React.FC<OrganizationStrategyProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div>
|
<div className="flex items-start justify-between gap-4">
|
||||||
<h4 className="text-sm font-medium mb-3 flex items-center gap-2">
|
<div className="flex-1">
|
||||||
|
<h4 className="text-sm font-medium mb-3 flex items-center gap-2">
|
||||||
<Building className="h-4 w-4" />
|
<Building className="h-4 w-4" />
|
||||||
Organization Strategy
|
Organization Strategy
|
||||||
</h4>
|
</h4>
|
||||||
<p className="text-xs text-muted-foreground mb-4">
|
<p className="text-xs text-muted-foreground">
|
||||||
Choose how your repositories will be organized in Gitea
|
Choose how your repositories will be organized in Gitea
|
||||||
</p>
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex-shrink-0">
|
||||||
|
<HoverCard openDelay={200}>
|
||||||
|
<HoverCardTrigger asChild>
|
||||||
|
<button
|
||||||
|
className="inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted rounded-md transition-colors"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<Info className="h-3.5 w-3.5" />
|
||||||
|
<span>Override Options</span>
|
||||||
|
</button>
|
||||||
|
</HoverCardTrigger>
|
||||||
|
<HoverCardContent side="left" align="start" className="w-[380px]">
|
||||||
|
<div className="space-y-3">
|
||||||
|
<div>
|
||||||
|
<h4 className="font-medium text-sm mb-1.5">Fine-tune Your Mirror Destinations</h4>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
After selecting a strategy, you can customize destinations for specific organizations and repositories.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2.5 pt-2 border-t">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Building2 className="h-3.5 w-3.5 text-primary" />
|
||||||
|
<span className="text-xs font-medium">Organization Overrides</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground pl-5">
|
||||||
|
Click the edit button on any organization card to redirect all its repositories to a different Gitea organization.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<GitBranch className="h-3.5 w-3.5 text-primary" />
|
||||||
|
<span className="text-xs font-medium">Repository Overrides</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground pl-5">
|
||||||
|
Use the inline editor in the repository table's "Destination" column to set custom destinations for individual repositories.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-1">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Star className="h-3.5 w-3.5 text-yellow-500" />
|
||||||
|
<span className="text-xs font-medium">Starred Repositories</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-xs text-muted-foreground pl-5">
|
||||||
|
Always go to the configured starred repos organization and cannot be overridden.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="pt-2 border-t">
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
<span className="font-medium">Priority:</span> Repository override → Organization override → Strategy default
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</HoverCardContent>
|
||||||
|
</HoverCard>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<RadioGroup value={strategy} onValueChange={onStrategyChange}>
|
<RadioGroup value={strategy} onValueChange={onStrategyChange}>
|
||||||
@@ -275,17 +397,16 @@ export const OrganizationStrategy: React.FC<OrganizationStrategyProps> = ({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Popover>
|
<HoverCard openDelay={200}>
|
||||||
<PopoverTrigger asChild>
|
<HoverCardTrigger asChild>
|
||||||
<button
|
<span
|
||||||
type="button"
|
className="inline-flex p-1.5 hover:bg-muted rounded-md transition-colors cursor-help"
|
||||||
className="p-1.5 hover:bg-muted rounded-md transition-colors"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<Info className="h-4 w-4 text-muted-foreground" />
|
<Info className="h-4 w-4 text-muted-foreground" />
|
||||||
</button>
|
</span>
|
||||||
</PopoverTrigger>
|
</HoverCardTrigger>
|
||||||
<PopoverContent side="left" align="center" className="w-[500px]">
|
<HoverCardContent side="left" align="center" className="w-[500px]">
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<h4 className="font-medium text-sm">Repository Mapping Preview</h4>
|
<h4 className="font-medium text-sm">Repository Mapping Preview</h4>
|
||||||
<MappingPreview
|
<MappingPreview
|
||||||
@@ -297,8 +418,8 @@ export const OrganizationStrategy: React.FC<OrganizationStrategyProps> = ({
|
|||||||
giteaUsername={giteaUsername}
|
giteaUsername={giteaUsername}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</HoverCardContent>
|
||||||
</Popover>
|
</HoverCard>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
193
src/components/organizations/MirrorDestinationEditor.tsx
Normal file
193
src/components/organizations/MirrorDestinationEditor.tsx
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { ArrowRight, Edit3, RotateCcw, CheckCircle2, Building2 } from "lucide-react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Label } from "@/components/ui/label";
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
PopoverContent,
|
||||||
|
PopoverTrigger,
|
||||||
|
} from "@/components/ui/popover";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { toast } from "sonner";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
interface MirrorDestinationEditorProps {
|
||||||
|
organizationId: string;
|
||||||
|
organizationName: string;
|
||||||
|
currentDestination?: string;
|
||||||
|
onUpdate: (newDestination: string | null) => Promise<void>;
|
||||||
|
isUpdating?: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MirrorDestinationEditor({
|
||||||
|
organizationId,
|
||||||
|
organizationName,
|
||||||
|
currentDestination,
|
||||||
|
onUpdate,
|
||||||
|
isUpdating = false,
|
||||||
|
className,
|
||||||
|
}: MirrorDestinationEditorProps) {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const [editValue, setEditValue] = useState(currentDestination || "");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
|
const hasOverride = currentDestination && currentDestination !== organizationName;
|
||||||
|
const effectiveDestination = currentDestination || organizationName;
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
const trimmedValue = editValue.trim();
|
||||||
|
const newDestination = trimmedValue === "" || trimmedValue === organizationName
|
||||||
|
? null
|
||||||
|
: trimmedValue;
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onUpdate(newDestination);
|
||||||
|
setIsOpen(false);
|
||||||
|
toast.success(
|
||||||
|
newDestination
|
||||||
|
? `Destination updated to: ${newDestination}`
|
||||||
|
: "Destination reset to default"
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
toast.error("Failed to update destination");
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleReset = async () => {
|
||||||
|
setEditValue("");
|
||||||
|
await handleSave();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
setEditValue(currentDestination || "");
|
||||||
|
setIsOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn("flex items-center gap-2", className)}>
|
||||||
|
<div className="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||||
|
<Building2 className="h-3 w-3" />
|
||||||
|
<span className="font-medium">{organizationName}</span>
|
||||||
|
<ArrowRight className="h-3 w-3" />
|
||||||
|
<span className={cn(
|
||||||
|
"font-medium",
|
||||||
|
hasOverride && "text-orange-600 dark:text-orange-400"
|
||||||
|
)}>
|
||||||
|
{effectiveDestination}
|
||||||
|
</span>
|
||||||
|
{hasOverride && (
|
||||||
|
<Badge variant="outline" className="h-4 px-1 text-[10px] border-orange-600 text-orange-600 dark:border-orange-400 dark:text-orange-400">
|
||||||
|
custom
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
||||||
|
<PopoverTrigger asChild>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-6 w-6 p-0 opacity-60 hover:opacity-100"
|
||||||
|
title="Edit mirror destination"
|
||||||
|
disabled={isUpdating || isLoading}
|
||||||
|
>
|
||||||
|
<Edit3 className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent className="w-80" align="end">
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div>
|
||||||
|
<h4 className="font-medium text-sm mb-1">Mirror Destination</h4>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Customize where this organization's repositories are mirrored to in Gitea.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3">
|
||||||
|
{/* Visual Preview */}
|
||||||
|
<div className="rounded-md bg-muted/50 p-3 space-y-2">
|
||||||
|
<div className="text-xs font-medium text-muted-foreground">Preview</div>
|
||||||
|
<div className="flex items-center gap-2 text-sm">
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<Building2 className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<span>{organizationName}</span>
|
||||||
|
</div>
|
||||||
|
<ArrowRight className="h-4 w-4 text-muted-foreground" />
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<Building2 className="h-4 w-4 text-primary" />
|
||||||
|
<span className="font-medium text-primary">
|
||||||
|
{editValue.trim() || organizationName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Input Field */}
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="destination" className="text-xs">
|
||||||
|
Destination Organization
|
||||||
|
</Label>
|
||||||
|
<Input
|
||||||
|
id="destination"
|
||||||
|
value={editValue}
|
||||||
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
|
placeholder={organizationName}
|
||||||
|
className="h-8"
|
||||||
|
disabled={isLoading}
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
Leave empty to use the default GitHub organization name
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Quick Actions */}
|
||||||
|
{hasOverride && (
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleReset}
|
||||||
|
disabled={isLoading}
|
||||||
|
className="w-full h-8 text-xs"
|
||||||
|
>
|
||||||
|
<RotateCcw className="h-3 w-3 mr-2" />
|
||||||
|
Reset to Default ({organizationName})
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Action Buttons */}
|
||||||
|
<div className="flex gap-2 justify-end">
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleCancel}
|
||||||
|
disabled={isLoading}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={isLoading || (editValue.trim() === (currentDestination || ""))}
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<>
|
||||||
|
<CheckCircle2 className="h-3 w-3 mr-2 animate-spin" />
|
||||||
|
Saving...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
"Save"
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -404,6 +404,7 @@ export function Organization() {
|
|||||||
loadingOrgIds={loadingOrgIds}
|
loadingOrgIds={loadingOrgIds}
|
||||||
onMirror={handleMirrorOrg}
|
onMirror={handleMirrorOrg}
|
||||||
onAddOrganization={() => setIsDialogOpen(true)}
|
onAddOrganization={() => setIsDialogOpen(true)}
|
||||||
|
onRefresh={() => fetchOrganizations(false)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AddOrganizationDialog
|
<AddOrganizationDialog
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { Card } from "@/components/ui/card";
|
import { Card } from "@/components/ui/card";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Plus, RefreshCw, Building2 } from "lucide-react";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { SiGithub } from "react-icons/si";
|
import { Plus, RefreshCw, Building2, Check, AlertCircle, Clock } from "lucide-react";
|
||||||
|
import { SiGithub, SiGitea } from "react-icons/si";
|
||||||
import type { Organization } from "@/lib/db/schema";
|
import type { Organization } from "@/lib/db/schema";
|
||||||
import type { FilterParams } from "@/types/filter";
|
import type { FilterParams } from "@/types/filter";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { cn } from "@/lib/utils";
|
||||||
import { getStatusColor } from "@/lib/utils";
|
import { MirrorDestinationEditor } from "./MirrorDestinationEditor";
|
||||||
|
import { useGiteaConfig } from "@/hooks/useGiteaConfig";
|
||||||
|
|
||||||
interface OrganizationListProps {
|
interface OrganizationListProps {
|
||||||
organizations: Organization[];
|
organizations: Organization[];
|
||||||
@@ -18,8 +20,25 @@ interface OrganizationListProps {
|
|||||||
onMirror: ({ orgId }: { orgId: string }) => Promise<void>;
|
onMirror: ({ orgId }: { orgId: string }) => Promise<void>;
|
||||||
loadingOrgIds: Set<string>;
|
loadingOrgIds: Set<string>;
|
||||||
onAddOrganization?: () => void;
|
onAddOrganization?: () => void;
|
||||||
|
onRefresh?: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to get status badge variant and icon
|
||||||
|
const getStatusBadge = (status: string | null) => {
|
||||||
|
switch (status) {
|
||||||
|
case "imported":
|
||||||
|
return { variant: "secondary" as const, label: "Not Mirrored", icon: null };
|
||||||
|
case "mirroring":
|
||||||
|
return { variant: "outline" as const, label: "Mirroring", icon: Clock };
|
||||||
|
case "mirrored":
|
||||||
|
return { variant: "default" as const, label: "Mirrored", icon: Check };
|
||||||
|
case "failed":
|
||||||
|
return { variant: "destructive" as const, label: "Failed", icon: AlertCircle };
|
||||||
|
default:
|
||||||
|
return { variant: "secondary" as const, label: "Unknown", icon: null };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export function OrganizationList({
|
export function OrganizationList({
|
||||||
organizations,
|
organizations,
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -28,7 +47,59 @@ export function OrganizationList({
|
|||||||
onMirror,
|
onMirror,
|
||||||
loadingOrgIds,
|
loadingOrgIds,
|
||||||
onAddOrganization,
|
onAddOrganization,
|
||||||
|
onRefresh,
|
||||||
}: OrganizationListProps) {
|
}: OrganizationListProps) {
|
||||||
|
const { giteaConfig } = useGiteaConfig();
|
||||||
|
|
||||||
|
// Helper function to construct Gitea organization URL
|
||||||
|
const getGiteaOrgUrl = (organization: Organization): string | null => {
|
||||||
|
if (!giteaConfig?.url) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only provide Gitea links for organizations that have been mirrored
|
||||||
|
const validStatuses = ['mirroring', 'mirrored'];
|
||||||
|
if (!validStatuses.includes(organization.status || '')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use destinationOrg if available, otherwise use the organization name
|
||||||
|
const orgName = organization.destinationOrg || organization.name;
|
||||||
|
if (!orgName) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the base URL doesn't have a trailing slash
|
||||||
|
const baseUrl = giteaConfig.url.endsWith('/')
|
||||||
|
? giteaConfig.url.slice(0, -1)
|
||||||
|
: giteaConfig.url;
|
||||||
|
|
||||||
|
return `${baseUrl}/${orgName}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleUpdateDestination = async (orgId: string, newDestination: string | null) => {
|
||||||
|
// Call API to update organization destination
|
||||||
|
const response = await fetch(`/api/organizations/${orgId}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
destinationOrg: newDestination,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
throw new Error(errorData.error || "Failed to update organization");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh organizations data
|
||||||
|
if (onRefresh) {
|
||||||
|
await onRefresh();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const hasAnyFilter = Object.values(filter).some(
|
const hasAnyFilter = Object.values(filter).some(
|
||||||
(val) => val?.toString().trim() !== ""
|
(val) => val?.toString().trim() !== ""
|
||||||
);
|
);
|
||||||
@@ -93,29 +164,56 @@ export function OrganizationList({
|
|||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||||
{filteredOrganizations.map((org, index) => {
|
{filteredOrganizations.map((org, index) => {
|
||||||
const isLoading = loadingOrgIds.has(org.id ?? "");
|
const isLoading = loadingOrgIds.has(org.id ?? "");
|
||||||
|
const statusBadge = getStatusBadge(org.status);
|
||||||
|
const StatusIcon = statusBadge.icon;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card key={index} className="overflow-hidden p-4">
|
<Card
|
||||||
<div className="flex items-center justify-between mb-2">
|
key={index}
|
||||||
<div className="flex items-center gap-2">
|
className={cn(
|
||||||
<Building2 className="h-5 w-5 text-muted-foreground" />
|
"overflow-hidden p-4 transition-all hover:shadow-md min-h-[160px]",
|
||||||
<a
|
isLoading && "opacity-75"
|
||||||
href={`/repositories?organization=${encodeURIComponent(org.name || '')}`}
|
)}
|
||||||
className="font-medium hover:underline cursor-pointer"
|
>
|
||||||
>
|
<div className="flex items-start justify-between mb-3">
|
||||||
{org.name}
|
<div className="flex-1">
|
||||||
</a>
|
<div className="flex items-center gap-2 mb-1">
|
||||||
|
<Building2 className="h-5 w-5 text-muted-foreground" />
|
||||||
|
<a
|
||||||
|
href={`/repositories?organization=${encodeURIComponent(org.name || '')}`}
|
||||||
|
className="font-medium hover:underline cursor-pointer"
|
||||||
|
>
|
||||||
|
{org.name}
|
||||||
|
</a>
|
||||||
|
<span
|
||||||
|
className={`text-xs px-2 py-0.5 rounded-full capitalize ${
|
||||||
|
org.membershipRole === "member"
|
||||||
|
? "bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"
|
||||||
|
: "bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{org.membershipRole}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Destination override section */}
|
||||||
|
<div className="mt-2">
|
||||||
|
<MirrorDestinationEditor
|
||||||
|
organizationId={org.id!}
|
||||||
|
organizationName={org.name!}
|
||||||
|
currentDestination={org.destinationOrg}
|
||||||
|
onUpdate={(newDestination) => handleUpdateDestination(org.id!, newDestination)}
|
||||||
|
isUpdating={isLoading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span
|
<Badge variant={statusBadge.variant} className="ml-2">
|
||||||
className={`text-xs px-2 py-1 rounded-full capitalize ${
|
{StatusIcon && <StatusIcon className={cn(
|
||||||
org.membershipRole === "member"
|
"h-3 w-3",
|
||||||
? "bg-blue-100 text-blue-800"
|
org.status === "mirroring" && "animate-pulse"
|
||||||
: "bg-purple-100 text-purple-800"
|
)} />}
|
||||||
}`}
|
{statusBadge.label}
|
||||||
>
|
</Badge>
|
||||||
{org.membershipRole}
|
|
||||||
{/* needs to be updated */}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="text-sm text-muted-foreground mb-4">
|
<div className="text-sm text-muted-foreground mb-4">
|
||||||
@@ -125,78 +223,147 @@ export function OrganizationList({
|
|||||||
{org.repositoryCount === 1 ? "repository" : "repositories"}
|
{org.repositoryCount === 1 ? "repository" : "repositories"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{(org.publicRepositoryCount !== undefined ||
|
{/* Always render this section to prevent layout shift */}
|
||||||
org.privateRepositoryCount !== undefined ||
|
<div className="flex gap-4 mt-2 text-xs min-h-[20px]">
|
||||||
org.forkRepositoryCount !== undefined) && (
|
{isLoading || (org.status === "mirroring" && org.publicRepositoryCount === undefined) ? (
|
||||||
<div className="flex gap-4 mt-2 text-xs">
|
<>
|
||||||
{org.publicRepositoryCount !== undefined && (
|
<Skeleton className="h-3 w-16" />
|
||||||
<span className="flex items-center gap-1">
|
<Skeleton className="h-3 w-16" />
|
||||||
<div className="h-2 w-2 rounded-full bg-green-500" />
|
</>
|
||||||
{org.publicRepositoryCount} public
|
) : (
|
||||||
</span>
|
<>
|
||||||
)}
|
{org.publicRepositoryCount !== undefined ? (
|
||||||
{org.privateRepositoryCount !== undefined && org.privateRepositoryCount > 0 && (
|
<span className="flex items-center gap-1">
|
||||||
<span className="flex items-center gap-1">
|
<div className="h-2 w-2 rounded-full bg-green-500" />
|
||||||
<div className="h-2 w-2 rounded-full bg-orange-500" />
|
{org.publicRepositoryCount} public
|
||||||
{org.privateRepositoryCount} private
|
</span>
|
||||||
</span>
|
) : null}
|
||||||
)}
|
{org.privateRepositoryCount !== undefined && org.privateRepositoryCount > 0 ? (
|
||||||
{org.forkRepositoryCount !== undefined && org.forkRepositoryCount > 0 && (
|
<span className="flex items-center gap-1">
|
||||||
<span className="flex items-center gap-1">
|
<div className="h-2 w-2 rounded-full bg-orange-500" />
|
||||||
<div className="h-2 w-2 rounded-full bg-blue-500" />
|
{org.privateRepositoryCount} private
|
||||||
{org.forkRepositoryCount} fork{org.forkRepositoryCount !== 1 ? 's' : ''}
|
</span>
|
||||||
</span>
|
) : null}
|
||||||
)}
|
{org.forkRepositoryCount !== undefined && org.forkRepositoryCount > 0 ? (
|
||||||
</div>
|
<span className="flex items-center gap-1">
|
||||||
)}
|
<div className="h-2 w-2 rounded-full bg-blue-500" />
|
||||||
|
{org.forkRepositoryCount} fork{org.forkRepositoryCount !== 1 ? 's' : ''}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
{/* Show a placeholder if no counts are available to maintain height */}
|
||||||
|
{org.publicRepositoryCount === undefined &&
|
||||||
|
org.privateRepositoryCount === undefined &&
|
||||||
|
org.forkRepositoryCount === undefined && (
|
||||||
|
<span className="invisible">Loading counts...</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-2">
|
||||||
<Checkbox
|
{org.status === "imported" && (
|
||||||
id={`include-${org.id}`}
|
<Button
|
||||||
name={`include-${org.id}`}
|
size="sm"
|
||||||
checked={org.status === "mirrored"}
|
onClick={() => org.id && onMirror({ orgId: org.id })}
|
||||||
disabled={
|
disabled={isLoading}
|
||||||
loadingOrgIds.has(org.id ?? "") ||
|
>
|
||||||
org.status === "mirrored" ||
|
{isLoading ? (
|
||||||
org.status === "mirroring"
|
<>
|
||||||
}
|
<RefreshCw className="h-3 w-3 animate-spin mr-2" />
|
||||||
onCheckedChange={async (checked) => {
|
Starting...
|
||||||
if (checked && !org.isIncluded && org.id) {
|
</>
|
||||||
onMirror({ orgId: org.id });
|
) : (
|
||||||
}
|
"Mirror"
|
||||||
}}
|
)}
|
||||||
/>
|
</Button>
|
||||||
<label
|
)}
|
||||||
htmlFor={`include-${org.id}`}
|
|
||||||
className="ml-2 text-sm select-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
{org.status === "mirroring" && (
|
||||||
>
|
<Button size="sm" disabled variant="outline">
|
||||||
Enable mirroring
|
<RefreshCw className="h-3 w-3 animate-spin mr-2" />
|
||||||
</label>
|
Mirroring...
|
||||||
|
</Button>
|
||||||
{isLoading && (
|
)}
|
||||||
<RefreshCw className="opacity-50 h-4 w-4 animate-spin ml-4" />
|
|
||||||
|
{org.status === "mirrored" && (
|
||||||
|
<Button size="sm" disabled variant="secondary">
|
||||||
|
<Check className="h-3 w-3 mr-2" />
|
||||||
|
Mirrored
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{org.status === "failed" && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="destructive"
|
||||||
|
onClick={() => org.id && onMirror({ orgId: org.id })}
|
||||||
|
disabled={isLoading}
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<>
|
||||||
|
<RefreshCw className="h-3 w-3 animate-spin mr-2" />
|
||||||
|
Retrying...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<AlertCircle className="h-3 w-3 mr-2" />
|
||||||
|
Retry
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button variant="ghost" size="icon" asChild>
|
<div className="flex items-center gap-1">
|
||||||
<a
|
{(() => {
|
||||||
href={`https://github.com/${org.name}`}
|
const giteaUrl = getGiteaOrgUrl(org);
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<SiGithub className="h-4 w-4" />
|
|
||||||
</a>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* dont know if this looks good. maybe revised */}
|
// Determine tooltip based on status and configuration
|
||||||
<div className="flex items-center gap-2 justify-end mt-4">
|
let tooltip: string;
|
||||||
<div
|
if (!giteaConfig?.url) {
|
||||||
className={`h-2 w-2 rounded-full ${getStatusColor(org.status)}`}
|
tooltip = "Gitea not configured";
|
||||||
/>
|
} else if (org.status === 'imported') {
|
||||||
<span className="text-sm capitalize">{org.status}</span>
|
tooltip = "Organization not yet mirrored to Gitea";
|
||||||
|
} else if (org.status === 'failed') {
|
||||||
|
tooltip = "Organization mirroring failed";
|
||||||
|
} else if (org.status === 'mirroring') {
|
||||||
|
tooltip = "Organization is being mirrored to Gitea";
|
||||||
|
} else if (giteaUrl) {
|
||||||
|
tooltip = "View on Gitea";
|
||||||
|
} else {
|
||||||
|
tooltip = "Gitea organization not available";
|
||||||
|
}
|
||||||
|
|
||||||
|
return giteaUrl ? (
|
||||||
|
<Button variant="ghost" size="icon" asChild>
|
||||||
|
<a
|
||||||
|
href={giteaUrl}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
title={tooltip}
|
||||||
|
>
|
||||||
|
<SiGitea className="h-4 w-4" />
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button variant="ghost" size="icon" disabled title={tooltip}>
|
||||||
|
<SiGitea className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
<Button variant="ghost" size="icon" asChild>
|
||||||
|
<a
|
||||||
|
href={`https://github.com/${org.name}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
title="View on GitHub"
|
||||||
|
>
|
||||||
|
<SiGithub className="h-4 w-4" />
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
187
src/components/repositories/InlineDestinationEditor.tsx
Normal file
187
src/components/repositories/InlineDestinationEditor.tsx
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import { useState, useRef, useEffect } from "react";
|
||||||
|
import { Edit3, Check, X } from "lucide-react";
|
||||||
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Input } from "@/components/ui/input";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import type { Repository } from "@/lib/db/schema";
|
||||||
|
|
||||||
|
interface InlineDestinationEditorProps {
|
||||||
|
repository: Repository;
|
||||||
|
giteaConfig: any;
|
||||||
|
onUpdate: (repoId: string, newDestination: string | null) => Promise<void>;
|
||||||
|
isUpdating?: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function InlineDestinationEditor({
|
||||||
|
repository,
|
||||||
|
giteaConfig,
|
||||||
|
onUpdate,
|
||||||
|
isUpdating = false,
|
||||||
|
className,
|
||||||
|
}: InlineDestinationEditorProps) {
|
||||||
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
const [editValue, setEditValue] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
// Determine the default destination based on repository properties and config
|
||||||
|
const getDefaultDestination = () => {
|
||||||
|
// Starred repos always go to the configured starredReposOrg
|
||||||
|
if (repository.isStarred && giteaConfig?.starredReposOrg) {
|
||||||
|
return giteaConfig.starredReposOrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check mirror strategy
|
||||||
|
const strategy = giteaConfig?.mirrorStrategy || 'preserve';
|
||||||
|
|
||||||
|
if (strategy === 'single-org' && giteaConfig?.organization) {
|
||||||
|
// All repos go to a single organization
|
||||||
|
return giteaConfig.organization;
|
||||||
|
} else if (strategy === 'flat-user') {
|
||||||
|
// All repos go under the user account
|
||||||
|
return giteaConfig?.username || repository.owner;
|
||||||
|
} else {
|
||||||
|
// 'preserve' strategy or default
|
||||||
|
// For organization repos, use the organization name
|
||||||
|
if (repository.organization) {
|
||||||
|
return repository.organization;
|
||||||
|
}
|
||||||
|
// For personal repos, check if personalReposOrg is configured
|
||||||
|
if (!repository.organization && giteaConfig?.personalReposOrg) {
|
||||||
|
return giteaConfig.personalReposOrg;
|
||||||
|
}
|
||||||
|
// Default to the gitea username or owner
|
||||||
|
return giteaConfig?.username || repository.owner;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const defaultDestination = getDefaultDestination();
|
||||||
|
const currentDestination = repository.destinationOrg || defaultDestination;
|
||||||
|
const hasOverride = repository.destinationOrg && repository.destinationOrg !== defaultDestination;
|
||||||
|
const isStarredRepo = repository.isStarred && giteaConfig?.starredReposOrg;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isEditing && inputRef.current) {
|
||||||
|
inputRef.current.focus();
|
||||||
|
inputRef.current.select();
|
||||||
|
}
|
||||||
|
}, [isEditing]);
|
||||||
|
|
||||||
|
const handleStartEdit = () => {
|
||||||
|
if (isStarredRepo) return; // Don't allow editing starred repos
|
||||||
|
setEditValue(currentDestination);
|
||||||
|
setIsEditing(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
const trimmedValue = editValue.trim();
|
||||||
|
const newDestination = trimmedValue === defaultDestination ? null : trimmedValue;
|
||||||
|
|
||||||
|
if (trimmedValue === currentDestination) {
|
||||||
|
setIsEditing(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(true);
|
||||||
|
try {
|
||||||
|
await onUpdate(repository.id!, newDestination);
|
||||||
|
setIsEditing(false);
|
||||||
|
} catch (error) {
|
||||||
|
// Revert on error
|
||||||
|
setEditValue(currentDestination);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
setEditValue(currentDestination);
|
||||||
|
setIsEditing(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleSave();
|
||||||
|
} else if (e.key === "Escape") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleCancel();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isEditing) {
|
||||||
|
return (
|
||||||
|
<div className={cn("flex items-center gap-1", className)}>
|
||||||
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
|
value={editValue}
|
||||||
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
|
onBlur={handleCancel}
|
||||||
|
className="h-6 text-sm px-2 py-0 w-24"
|
||||||
|
disabled={isLoading}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-5 w-5 p-0"
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={isLoading}
|
||||||
|
>
|
||||||
|
<Check className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-5 w-5 p-0"
|
||||||
|
onClick={handleCancel}
|
||||||
|
disabled={isLoading}
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={cn("flex flex-col gap-0.5", className)}>
|
||||||
|
{/* Show GitHub org if exists */}
|
||||||
|
{repository.organization && (
|
||||||
|
<span className="text-xs text-muted-foreground">
|
||||||
|
{repository.organization}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Show Gitea destination */}
|
||||||
|
<div className="flex items-center gap-1 group">
|
||||||
|
<span className="text-sm">
|
||||||
|
{currentDestination || "-"}
|
||||||
|
</span>
|
||||||
|
{hasOverride && (
|
||||||
|
<Badge variant="outline" className="h-4 px-1 text-[10px] ml-1">
|
||||||
|
custom
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
{isStarredRepo && (
|
||||||
|
<Badge variant="secondary" className="h-4 px-1 text-[10px] ml-1">
|
||||||
|
starred
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
{!isStarredRepo && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-4 w-4 p-0 opacity-0 group-hover:opacity-60 hover:opacity-100 ml-1"
|
||||||
|
onClick={handleStartEdit}
|
||||||
|
disabled={isUpdating || isLoading}
|
||||||
|
title="Edit destination"
|
||||||
|
>
|
||||||
|
<Edit3 className="h-3 w-3" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
SelectValue,
|
SelectValue,
|
||||||
} from "../ui/select";
|
} from "../ui/select";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Search, RefreshCw, FlipHorizontal } from "lucide-react";
|
import { Search, RefreshCw, FlipHorizontal, RotateCcw, X } from "lucide-react";
|
||||||
import type { MirrorRepoRequest, MirrorRepoResponse } from "@/types/mirror";
|
import type { MirrorRepoRequest, MirrorRepoResponse } from "@/types/mirror";
|
||||||
import { useSSE } from "@/hooks/useSEE";
|
import { useSSE } from "@/hooks/useSEE";
|
||||||
import { useFilterParams } from "@/hooks/useFilterParams";
|
import { useFilterParams } from "@/hooks/useFilterParams";
|
||||||
@@ -46,6 +46,7 @@ export default function Repository() {
|
|||||||
owner: "",
|
owner: "",
|
||||||
});
|
});
|
||||||
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
|
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(false);
|
||||||
|
const [selectedRepoIds, setSelectedRepoIds] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
// Read organization filter from URL when component mounts
|
// Read organization filter from URL when component mounts
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -254,6 +255,143 @@ export default function Repository() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Bulk action handlers
|
||||||
|
const handleBulkMirror = async () => {
|
||||||
|
if (selectedRepoIds.size === 0) return;
|
||||||
|
|
||||||
|
const selectedRepos = repositories.filter(repo => repo.id && selectedRepoIds.has(repo.id));
|
||||||
|
const eligibleRepos = selectedRepos.filter(
|
||||||
|
repo => repo.status === "imported" || repo.status === "failed"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (eligibleRepos.length === 0) {
|
||||||
|
toast.info("No eligible repositories to mirror in selection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repoIds = eligibleRepos.map(repo => repo.id as string);
|
||||||
|
|
||||||
|
setLoadingRepoIds(prev => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
repoIds.forEach(id => newSet.add(id));
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiRequest<MirrorRepoResponse>("/job/mirror-repo", {
|
||||||
|
method: "POST",
|
||||||
|
data: { userId: user?.id, repositoryIds: repoIds }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
toast.success(`Mirroring started for ${repoIds.length} repositories`);
|
||||||
|
setRepositories(prevRepos =>
|
||||||
|
prevRepos.map(repo => {
|
||||||
|
const updated = response.repositories.find(r => r.id === repo.id);
|
||||||
|
return updated ? updated : repo;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
setSelectedRepoIds(new Set());
|
||||||
|
} else {
|
||||||
|
showErrorToast(response.error || "Error starting mirror jobs", toast);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
showErrorToast(error, toast);
|
||||||
|
} finally {
|
||||||
|
setLoadingRepoIds(new Set());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkSync = async () => {
|
||||||
|
if (selectedRepoIds.size === 0) return;
|
||||||
|
|
||||||
|
const selectedRepos = repositories.filter(repo => repo.id && selectedRepoIds.has(repo.id));
|
||||||
|
const eligibleRepos = selectedRepos.filter(
|
||||||
|
repo => repo.status === "mirrored" || repo.status === "synced"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (eligibleRepos.length === 0) {
|
||||||
|
toast.info("No eligible repositories to sync in selection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repoIds = eligibleRepos.map(repo => repo.id as string);
|
||||||
|
|
||||||
|
setLoadingRepoIds(prev => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
repoIds.forEach(id => newSet.add(id));
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiRequest<SyncRepoResponse>("/job/sync-repo", {
|
||||||
|
method: "POST",
|
||||||
|
data: { userId: user?.id, repositoryIds: repoIds }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
toast.success(`Syncing started for ${repoIds.length} repositories`);
|
||||||
|
setRepositories(prevRepos =>
|
||||||
|
prevRepos.map(repo => {
|
||||||
|
const updated = response.repositories.find(r => r.id === repo.id);
|
||||||
|
return updated ? updated : repo;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
setSelectedRepoIds(new Set());
|
||||||
|
} else {
|
||||||
|
showErrorToast(response.error || "Error starting sync jobs", toast);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
showErrorToast(error, toast);
|
||||||
|
} finally {
|
||||||
|
setLoadingRepoIds(new Set());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBulkRetry = async () => {
|
||||||
|
if (selectedRepoIds.size === 0) return;
|
||||||
|
|
||||||
|
const selectedRepos = repositories.filter(repo => repo.id && selectedRepoIds.has(repo.id));
|
||||||
|
const eligibleRepos = selectedRepos.filter(repo => repo.status === "failed");
|
||||||
|
|
||||||
|
if (eligibleRepos.length === 0) {
|
||||||
|
toast.info("No failed repositories in selection to retry");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repoIds = eligibleRepos.map(repo => repo.id as string);
|
||||||
|
|
||||||
|
setLoadingRepoIds(prev => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
repoIds.forEach(id => newSet.add(id));
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiRequest<RetryRepoResponse>("/job/retry-repo", {
|
||||||
|
method: "POST",
|
||||||
|
data: { userId: user?.id, repositoryIds: repoIds }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
toast.success(`Retrying ${repoIds.length} repositories`);
|
||||||
|
setRepositories(prevRepos =>
|
||||||
|
prevRepos.map(repo => {
|
||||||
|
const updated = response.repositories.find(r => r.id === repo.id);
|
||||||
|
return updated ? updated : repo;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
setSelectedRepoIds(new Set());
|
||||||
|
} else {
|
||||||
|
showErrorToast(response.error || "Error retrying jobs", toast);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
showErrorToast(error, toast);
|
||||||
|
} finally {
|
||||||
|
setLoadingRepoIds(new Set());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSyncRepo = async ({ repoId }: { repoId: string }) => {
|
const handleSyncRepo = async ({ repoId }: { repoId: string }) => {
|
||||||
try {
|
try {
|
||||||
if (!user || !user.id) {
|
if (!user || !user.id) {
|
||||||
@@ -392,6 +530,35 @@ export default function Repository() {
|
|||||||
)
|
)
|
||||||
).sort();
|
).sort();
|
||||||
|
|
||||||
|
// Determine what actions are available for selected repositories
|
||||||
|
const getAvailableActions = () => {
|
||||||
|
if (selectedRepoIds.size === 0) return [];
|
||||||
|
|
||||||
|
const selectedRepos = repositories.filter(repo => repo.id && selectedRepoIds.has(repo.id));
|
||||||
|
const statuses = new Set(selectedRepos.map(repo => repo.status));
|
||||||
|
|
||||||
|
const actions = [];
|
||||||
|
|
||||||
|
// Check if any selected repos can be mirrored
|
||||||
|
if (selectedRepos.some(repo => repo.status === "imported" || repo.status === "failed")) {
|
||||||
|
actions.push('mirror');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if any selected repos can be synced
|
||||||
|
if (selectedRepos.some(repo => repo.status === "mirrored" || repo.status === "synced")) {
|
||||||
|
actions.push('sync');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if any selected repos are failed
|
||||||
|
if (selectedRepos.some(repo => repo.status === "failed")) {
|
||||||
|
actions.push('retry');
|
||||||
|
}
|
||||||
|
|
||||||
|
return actions;
|
||||||
|
};
|
||||||
|
|
||||||
|
const availableActions = getAvailableActions();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-y-8">
|
<div className="flex flex-col gap-y-8">
|
||||||
{/* Combine search and actions into a single flex row */}
|
{/* Combine search and actions into a single flex row */}
|
||||||
@@ -459,14 +626,69 @@ export default function Repository() {
|
|||||||
<RefreshCw className="h-4 w-4" />
|
<RefreshCw className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
{/* Context-aware action buttons */}
|
||||||
variant="default"
|
{selectedRepoIds.size === 0 ? (
|
||||||
onClick={handleMirrorAllRepos}
|
<Button
|
||||||
disabled={isInitialLoading || loadingRepoIds.size > 0}
|
variant="default"
|
||||||
>
|
onClick={handleMirrorAllRepos}
|
||||||
<FlipHorizontal className="h-4 w-4 mr-2" />
|
disabled={isInitialLoading || loadingRepoIds.size > 0}
|
||||||
Mirror All
|
>
|
||||||
</Button>
|
<FlipHorizontal className="h-4 w-4 mr-2" />
|
||||||
|
Mirror All
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<div className="flex items-center gap-2 px-3 py-1 bg-muted/50 rounded-md">
|
||||||
|
<span className="text-sm font-medium">
|
||||||
|
{selectedRepoIds.size} selected
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
className="h-6 w-6"
|
||||||
|
onClick={() => setSelectedRepoIds(new Set())}
|
||||||
|
>
|
||||||
|
<X className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{availableActions.includes('mirror') && (
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleBulkMirror}
|
||||||
|
disabled={loadingRepoIds.size > 0}
|
||||||
|
>
|
||||||
|
<FlipHorizontal className="h-4 w-4 mr-2" />
|
||||||
|
Mirror ({selectedRepoIds.size})
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{availableActions.includes('sync') && (
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleBulkSync}
|
||||||
|
disabled={loadingRepoIds.size > 0}
|
||||||
|
>
|
||||||
|
<RefreshCw className="h-4 w-4 mr-2" />
|
||||||
|
Sync ({selectedRepoIds.size})
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{availableActions.includes('retry') && (
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={handleBulkRetry}
|
||||||
|
disabled={loadingRepoIds.size > 0}
|
||||||
|
>
|
||||||
|
<RotateCcw className="h-4 w-4 mr-2" />
|
||||||
|
Retry
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!isGitHubConfigured ? (
|
{!isGitHubConfigured ? (
|
||||||
@@ -497,6 +719,9 @@ export default function Repository() {
|
|||||||
onSync={handleSyncRepo}
|
onSync={handleSyncRepo}
|
||||||
onRetry={handleRetryRepoAction}
|
onRetry={handleRetryRepoAction}
|
||||||
loadingRepoIds={loadingRepoIds}
|
loadingRepoIds={loadingRepoIds}
|
||||||
|
selectedRepoIds={selectedRepoIds}
|
||||||
|
onSelectionChange={setSelectedRepoIds}
|
||||||
|
onRefresh={() => fetchRepositories(false)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useMemo, useRef } from "react";
|
import { useMemo, useRef } from "react";
|
||||||
import Fuse from "fuse.js";
|
import Fuse from "fuse.js";
|
||||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||||
import { FlipHorizontal, GitFork, RefreshCw, RotateCcw } from "lucide-react";
|
import { FlipHorizontal, GitFork, RefreshCw, RotateCcw, Star } from "lucide-react";
|
||||||
import { SiGithub, SiGitea } from "react-icons/si";
|
import { SiGithub, SiGitea } from "react-icons/si";
|
||||||
import type { Repository } from "@/lib/db/schema";
|
import type { Repository } from "@/lib/db/schema";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
@@ -9,6 +9,14 @@ import { formatDate, getStatusColor } from "@/lib/utils";
|
|||||||
import type { FilterParams } from "@/types/filter";
|
import type { FilterParams } from "@/types/filter";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
import { useGiteaConfig } from "@/hooks/useGiteaConfig";
|
import { useGiteaConfig } from "@/hooks/useGiteaConfig";
|
||||||
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipProvider,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@/components/ui/tooltip";
|
||||||
|
import { InlineDestinationEditor } from "./InlineDestinationEditor";
|
||||||
|
|
||||||
interface RepositoryTableProps {
|
interface RepositoryTableProps {
|
||||||
repositories: Repository[];
|
repositories: Repository[];
|
||||||
@@ -20,6 +28,9 @@ interface RepositoryTableProps {
|
|||||||
onSync: ({ repoId }: { repoId: string }) => Promise<void>;
|
onSync: ({ repoId }: { repoId: string }) => Promise<void>;
|
||||||
onRetry: ({ repoId }: { repoId: string }) => Promise<void>;
|
onRetry: ({ repoId }: { repoId: string }) => Promise<void>;
|
||||||
loadingRepoIds: Set<string>;
|
loadingRepoIds: Set<string>;
|
||||||
|
selectedRepoIds: Set<string>;
|
||||||
|
onSelectionChange: (selectedIds: Set<string>) => void;
|
||||||
|
onRefresh?: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function RepositoryTable({
|
export default function RepositoryTable({
|
||||||
@@ -32,10 +43,36 @@ export default function RepositoryTable({
|
|||||||
onSync,
|
onSync,
|
||||||
onRetry,
|
onRetry,
|
||||||
loadingRepoIds,
|
loadingRepoIds,
|
||||||
|
selectedRepoIds,
|
||||||
|
onSelectionChange,
|
||||||
|
onRefresh,
|
||||||
}: RepositoryTableProps) {
|
}: RepositoryTableProps) {
|
||||||
const tableParentRef = useRef<HTMLDivElement>(null);
|
const tableParentRef = useRef<HTMLDivElement>(null);
|
||||||
const { giteaConfig } = useGiteaConfig();
|
const { giteaConfig } = useGiteaConfig();
|
||||||
|
|
||||||
|
const handleUpdateDestination = async (repoId: string, newDestination: string | null) => {
|
||||||
|
// Call API to update repository destination
|
||||||
|
const response = await fetch(`/api/repositories/${repoId}`, {
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
destinationOrg: newDestination,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
throw new Error(errorData.error || "Failed to update repository");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh repositories data
|
||||||
|
if (onRefresh) {
|
||||||
|
await onRefresh();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Helper function to construct Gitea repository URL
|
// Helper function to construct Gitea repository URL
|
||||||
const getGiteaRepoUrl = (repository: Repository): string | null => {
|
const getGiteaRepoUrl = (repository: Repository): string | null => {
|
||||||
if (!giteaConfig?.url) {
|
if (!giteaConfig?.url) {
|
||||||
@@ -105,9 +142,36 @@ export default function RepositoryTable({
|
|||||||
overscan: 5,
|
overscan: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Selection handlers
|
||||||
|
const handleSelectAll = (checked: boolean) => {
|
||||||
|
if (checked) {
|
||||||
|
const allIds = new Set(filteredRepositories.map(repo => repo.id).filter((id): id is string => !!id));
|
||||||
|
onSelectionChange(allIds);
|
||||||
|
} else {
|
||||||
|
onSelectionChange(new Set());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectRepo = (repoId: string, checked: boolean) => {
|
||||||
|
const newSelection = new Set(selectedRepoIds);
|
||||||
|
if (checked) {
|
||||||
|
newSelection.add(repoId);
|
||||||
|
} else {
|
||||||
|
newSelection.delete(repoId);
|
||||||
|
}
|
||||||
|
onSelectionChange(newSelection);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isAllSelected = filteredRepositories.length > 0 &&
|
||||||
|
filteredRepositories.every(repo => repo.id && selectedRepoIds.has(repo.id));
|
||||||
|
const isPartiallySelected = selectedRepoIds.size > 0 && !isAllSelected;
|
||||||
|
|
||||||
return isLoading ? (
|
return isLoading ? (
|
||||||
<div className="border rounded-md">
|
<div className="border rounded-md">
|
||||||
<div className="h-[45px] flex items-center justify-between border-b bg-muted/50">
|
<div className="h-[45px] flex items-center justify-between border-b bg-muted/50">
|
||||||
|
<div className="h-full p-3 flex items-center justify-center flex-[0.3]">
|
||||||
|
<Skeleton className="h-4 w-4" />
|
||||||
|
</div>
|
||||||
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
||||||
Repository
|
Repository
|
||||||
</div>
|
</div>
|
||||||
@@ -132,6 +196,9 @@ export default function RepositoryTable({
|
|||||||
key={i}
|
key={i}
|
||||||
className="h-[65px] flex items-center justify-between border-b bg-transparent"
|
className="h-[65px] flex items-center justify-between border-b bg-transparent"
|
||||||
>
|
>
|
||||||
|
<div className="h-full p-3 flex items-center justify-center flex-[0.3]">
|
||||||
|
<Skeleton className="h-4 w-4" />
|
||||||
|
</div>
|
||||||
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
||||||
<Skeleton className="h-full w-full" />
|
<Skeleton className="h-full w-full" />
|
||||||
</div>
|
</div>
|
||||||
@@ -187,6 +254,14 @@ export default function RepositoryTable({
|
|||||||
<div className="flex flex-col border rounded-md">
|
<div className="flex flex-col border rounded-md">
|
||||||
{/* table header */}
|
{/* table header */}
|
||||||
<div className="h-[45px] flex items-center justify-between border-b bg-muted/50">
|
<div className="h-[45px] flex items-center justify-between border-b bg-muted/50">
|
||||||
|
<div className="h-full p-3 flex items-center justify-center flex-[0.3]">
|
||||||
|
<Checkbox
|
||||||
|
checked={isAllSelected}
|
||||||
|
indeterminate={isPartiallySelected}
|
||||||
|
onCheckedChange={handleSelectAll}
|
||||||
|
aria-label="Select all repositories"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
<div className="h-full p-3 text-sm font-medium flex-[2.5]">
|
||||||
Repository
|
Repository
|
||||||
</div>
|
</div>
|
||||||
@@ -235,11 +310,25 @@ export default function RepositoryTable({
|
|||||||
data-index={virtualRow.index}
|
data-index={virtualRow.index}
|
||||||
className="h-[65px] flex items-center justify-between bg-transparent border-b hover:bg-muted/50" //the height is set according to the row content. right now the highest row is in the repo column which is arround 64.99px
|
className="h-[65px] flex items-center justify-between bg-transparent border-b hover:bg-muted/50" //the height is set according to the row content. right now the highest row is in the repo column which is arround 64.99px
|
||||||
>
|
>
|
||||||
|
{/* Checkbox */}
|
||||||
|
<div className="h-full p-3 flex items-center justify-center flex-[0.3]">
|
||||||
|
<Checkbox
|
||||||
|
checked={repo.id ? selectedRepoIds.has(repo.id) : false}
|
||||||
|
onCheckedChange={(checked) => repo.id && handleSelectRepo(repo.id, !!checked)}
|
||||||
|
aria-label={`Select ${repo.name}`}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Repository */}
|
{/* Repository */}
|
||||||
<div className="h-full p-3 flex items-center gap-2 flex-[2.5]">
|
<div className="h-full p-3 flex items-center gap-2 flex-[2.5]">
|
||||||
<GitFork className="h-4 w-4 text-muted-foreground" />
|
<GitFork className="h-4 w-4 text-muted-foreground" />
|
||||||
<div>
|
<div className="flex-1">
|
||||||
<div className="font-medium">{repo.name}</div>
|
<div className="font-medium flex items-center gap-1">
|
||||||
|
{repo.name}
|
||||||
|
{repo.isStarred && (
|
||||||
|
<Star className="h-3 w-3 fill-yellow-500 text-yellow-500" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div className="text-xs text-muted-foreground">
|
<div className="text-xs text-muted-foreground">
|
||||||
{repo.fullName}
|
{repo.fullName}
|
||||||
</div>
|
</div>
|
||||||
@@ -263,7 +352,12 @@ export default function RepositoryTable({
|
|||||||
|
|
||||||
{/* Organization */}
|
{/* Organization */}
|
||||||
<div className="h-full p-3 flex items-center flex-[1]">
|
<div className="h-full p-3 flex items-center flex-[1]">
|
||||||
<p className="text-sm"> {repo.organization || "-"}</p>
|
<InlineDestinationEditor
|
||||||
|
repository={repo}
|
||||||
|
giteaConfig={giteaConfig}
|
||||||
|
onUpdate={handleUpdateDestination}
|
||||||
|
isUpdating={loadingRepoIds.has(repo.id ?? "")}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Last Mirrored */}
|
{/* Last Mirrored */}
|
||||||
@@ -277,12 +371,26 @@ export default function RepositoryTable({
|
|||||||
|
|
||||||
{/* Status */}
|
{/* Status */}
|
||||||
<div className="h-full p-3 flex items-center gap-x-2 flex-[1]">
|
<div className="h-full p-3 flex items-center gap-x-2 flex-[1]">
|
||||||
<div
|
{repo.status === "failed" && repo.errorMessage ? (
|
||||||
className={`h-2 w-2 rounded-full ${getStatusColor(
|
<TooltipProvider>
|
||||||
repo.status
|
<Tooltip>
|
||||||
)}`}
|
<TooltipTrigger asChild>
|
||||||
/>
|
<div className="flex items-center gap-x-2 cursor-help">
|
||||||
<span className="text-sm capitalize">{repo.status}</span>
|
<div className={`h-2 w-2 rounded-full ${getStatusColor(repo.status)}`} />
|
||||||
|
<span className="text-sm capitalize underline decoration-dotted">{repo.status}</span>
|
||||||
|
</div>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent className="max-w-xs">
|
||||||
|
<p className="text-sm">{repo.errorMessage}</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<div className={`h-2 w-2 rounded-full ${getStatusColor(repo.status)}`} />
|
||||||
|
<span className="text-sm capitalize">{repo.status}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Actions */}
|
{/* Actions */}
|
||||||
|
|||||||
42
src/components/ui/hover-card.tsx
Normal file
42
src/components/ui/hover-card.tsx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function HoverCard({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
|
||||||
|
return <HoverCardPrimitive.Root data-slot="hover-card" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function HoverCardTrigger({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof HoverCardPrimitive.Trigger>) {
|
||||||
|
return (
|
||||||
|
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function HoverCardContent({
|
||||||
|
className,
|
||||||
|
align = "center",
|
||||||
|
sideOffset = 4,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
||||||
|
<HoverCardPrimitive.Content
|
||||||
|
data-slot="hover-card-content"
|
||||||
|
align={align}
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</HoverCardPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
||||||
@@ -28,11 +28,44 @@ try {
|
|||||||
|
|
||||||
// Ensure all required tables exist
|
// Ensure all required tables exist
|
||||||
ensureTablesExist(sqlite);
|
ensureTablesExist(sqlite);
|
||||||
|
|
||||||
|
// Run migrations
|
||||||
|
runMigrations(sqlite);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error opening database:", error);
|
console.error("Error opening database:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run database migrations
|
||||||
|
*/
|
||||||
|
function runMigrations(db: Database) {
|
||||||
|
try {
|
||||||
|
// Migration 1: Add destination_org column to organizations table
|
||||||
|
const orgTableInfo = db.query("PRAGMA table_info(organizations)").all() as Array<{name: string}>;
|
||||||
|
const hasDestinationOrg = orgTableInfo.some(col => col.name === 'destination_org');
|
||||||
|
|
||||||
|
if (!hasDestinationOrg) {
|
||||||
|
console.log("🔄 Running migration: Adding destination_org column to organizations table");
|
||||||
|
db.exec("ALTER TABLE organizations ADD COLUMN destination_org TEXT");
|
||||||
|
console.log("✅ Migration completed: destination_org column added");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Migration 2: Add destination_org column to repositories table
|
||||||
|
const repoTableInfo = db.query("PRAGMA table_info(repositories)").all() as Array<{name: string}>;
|
||||||
|
const hasRepoDestinationOrg = repoTableInfo.some(col => col.name === 'destination_org');
|
||||||
|
|
||||||
|
if (!hasRepoDestinationOrg) {
|
||||||
|
console.log("🔄 Running migration: Adding destination_org column to repositories table");
|
||||||
|
db.exec("ALTER TABLE repositories ADD COLUMN destination_org TEXT");
|
||||||
|
console.log("✅ Migration completed: destination_org column added to repositories");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("❌ Error running migrations:", error);
|
||||||
|
// Don't throw - migrations should be non-breaking
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure all required tables exist in the database
|
* Ensure all required tables exist in the database
|
||||||
*/
|
*/
|
||||||
@@ -159,6 +192,7 @@ function createTable(db: Database, tableName: string) {
|
|||||||
last_mirrored INTEGER,
|
last_mirrored INTEGER,
|
||||||
error_message TEXT,
|
error_message TEXT,
|
||||||
repository_count INTEGER NOT NULL DEFAULT 0,
|
repository_count INTEGER NOT NULL DEFAULT 0,
|
||||||
|
destination_org TEXT,
|
||||||
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
created_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
||||||
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
updated_at INTEGER NOT NULL DEFAULT (strftime('%s','now')),
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||||
@@ -437,6 +471,9 @@ export const organizations = sqliteTable("organizations", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
.default(true),
|
.default(true),
|
||||||
|
|
||||||
|
// Override destination organization for this GitHub org's repos
|
||||||
|
destinationOrg: text("destination_org"),
|
||||||
|
|
||||||
status: text("status").notNull().default("imported"),
|
status: text("status").notNull().default("imported"),
|
||||||
lastMirrored: integer("last_mirrored", { mode: "timestamp" }),
|
lastMirrored: integer("last_mirrored", { mode: "timestamp" }),
|
||||||
errorMessage: text("error_message"),
|
errorMessage: text("error_message"),
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ export const configSchema = z.object({
|
|||||||
visibility: z.enum(["public", "private", "limited"]).default("public"),
|
visibility: z.enum(["public", "private", "limited"]).default("public"),
|
||||||
starredReposOrg: z.string().default("github"),
|
starredReposOrg: z.string().default("github"),
|
||||||
preserveOrgStructure: z.boolean().default(false),
|
preserveOrgStructure: z.boolean().default(false),
|
||||||
mirrorStrategy: z.enum(["preserve", "single-org", "flat-user"]).optional(),
|
mirrorStrategy: z.enum(["preserve", "single-org", "flat-user", "mixed"]).optional(),
|
||||||
|
personalReposOrg: z.string().optional(), // Override destination for personal repos
|
||||||
}),
|
}),
|
||||||
include: z.array(z.string()).default(["*"]),
|
include: z.array(z.string()).default(["*"]),
|
||||||
exclude: z.array(z.string()).default([]),
|
exclude: z.array(z.string()).default([]),
|
||||||
@@ -100,6 +101,7 @@ export const repositorySchema = z.object({
|
|||||||
errorMessage: z.string().optional(),
|
errorMessage: z.string().optional(),
|
||||||
|
|
||||||
mirroredLocation: z.string().default(""), // Store the full Gitea path where repo was mirrored
|
mirroredLocation: z.string().default(""), // Store the full Gitea path where repo was mirrored
|
||||||
|
destinationOrg: z.string().optional(), // Custom destination organization override
|
||||||
|
|
||||||
createdAt: z.date().default(() => new Date()),
|
createdAt: z.date().default(() => new Date()),
|
||||||
updatedAt: z.date().default(() => new Date()),
|
updatedAt: z.date().default(() => new Date()),
|
||||||
@@ -158,6 +160,9 @@ export const organizationSchema = z.object({
|
|||||||
privateRepositoryCount: z.number().optional(),
|
privateRepositoryCount: z.number().optional(),
|
||||||
forkRepositoryCount: z.number().optional(),
|
forkRepositoryCount: z.number().optional(),
|
||||||
|
|
||||||
|
// Override destination organization for this GitHub org's repos
|
||||||
|
destinationOrg: z.string().optional(),
|
||||||
|
|
||||||
createdAt: z.date().default(() => new Date()),
|
createdAt: z.date().default(() => new Date()),
|
||||||
updatedAt: z.date().default(() => new Date()),
|
updatedAt: z.date().default(() => new Date()),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import { describe, test, expect, mock, beforeEach, afterEach } from "bun:test";
|
import { describe, test, expect, mock, beforeEach, afterEach } from "bun:test";
|
||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
import { repoStatusEnum } from "@/types/Repository";
|
import { repoStatusEnum } from "@/types/Repository";
|
||||||
import { getOrCreateGiteaOrg } from "./gitea";
|
import { getOrCreateGiteaOrg, getGiteaRepoOwner, getGiteaRepoOwnerAsync } from "./gitea";
|
||||||
|
import type { Config, Repository, Organization } from "./db/schema";
|
||||||
|
|
||||||
// Mock the isRepoPresentInGitea function
|
// Mock the isRepoPresentInGitea function
|
||||||
const mockIsRepoPresentInGitea = mock(() => Promise.resolve(false));
|
const mockIsRepoPresentInGitea = mock(() => Promise.resolve(false));
|
||||||
@@ -291,3 +292,133 @@ describe("Gitea Repository Mirroring", () => {
|
|||||||
expect(mockGetOrCreateGiteaOrg).toHaveBeenCalled();
|
expect(mockGetOrCreateGiteaOrg).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("getGiteaRepoOwner - Organization Override Tests", () => {
|
||||||
|
const baseConfig: Partial<Config> = {
|
||||||
|
githubConfig: {
|
||||||
|
username: "testuser",
|
||||||
|
token: "token",
|
||||||
|
preserveOrgStructure: false,
|
||||||
|
skipForks: false,
|
||||||
|
privateRepositories: false,
|
||||||
|
mirrorIssues: false,
|
||||||
|
mirrorWiki: false,
|
||||||
|
mirrorStarred: false,
|
||||||
|
useSpecificUser: false,
|
||||||
|
includeOrgs: [],
|
||||||
|
excludeOrgs: [],
|
||||||
|
mirrorPublicOrgs: false,
|
||||||
|
publicOrgs: [],
|
||||||
|
skipStarredIssues: false
|
||||||
|
},
|
||||||
|
giteaConfig: {
|
||||||
|
username: "giteauser",
|
||||||
|
url: "https://gitea.example.com",
|
||||||
|
token: "gitea-token",
|
||||||
|
organization: "github-mirrors",
|
||||||
|
visibility: "public",
|
||||||
|
starredReposOrg: "starred",
|
||||||
|
preserveOrgStructure: false,
|
||||||
|
mirrorStrategy: "preserve"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const baseRepo: Repository = {
|
||||||
|
id: "repo-id",
|
||||||
|
userId: "user-id",
|
||||||
|
configId: "config-id",
|
||||||
|
name: "test-repo",
|
||||||
|
fullName: "testuser/test-repo",
|
||||||
|
url: "https://github.com/testuser/test-repo",
|
||||||
|
cloneUrl: "https://github.com/testuser/test-repo.git",
|
||||||
|
owner: "testuser",
|
||||||
|
isPrivate: false,
|
||||||
|
isForked: false,
|
||||||
|
hasIssues: true,
|
||||||
|
isStarred: false,
|
||||||
|
isArchived: false,
|
||||||
|
size: 1000,
|
||||||
|
hasLFS: false,
|
||||||
|
hasSubmodules: false,
|
||||||
|
defaultBranch: "main",
|
||||||
|
visibility: "public",
|
||||||
|
status: "imported",
|
||||||
|
mirroredLocation: "",
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date()
|
||||||
|
};
|
||||||
|
|
||||||
|
test("starred repos go to starredReposOrg", () => {
|
||||||
|
const repo = { ...baseRepo, isStarred: true };
|
||||||
|
const result = getGiteaRepoOwner({ config: baseConfig, repository: repo });
|
||||||
|
expect(result).toBe("starred");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("preserve strategy: personal repos use personalReposOrg override", () => {
|
||||||
|
const configWithOverride = {
|
||||||
|
...baseConfig,
|
||||||
|
giteaConfig: {
|
||||||
|
...baseConfig.giteaConfig!,
|
||||||
|
personalReposOrg: "my-personal-mirrors"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const repo = { ...baseRepo, organization: undefined };
|
||||||
|
const result = getGiteaRepoOwner({ config: configWithOverride, repository: repo });
|
||||||
|
expect(result).toBe("my-personal-mirrors");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("preserve strategy: personal repos fallback to username when no override", () => {
|
||||||
|
const repo = { ...baseRepo, organization: undefined };
|
||||||
|
const result = getGiteaRepoOwner({ config: baseConfig, repository: repo });
|
||||||
|
expect(result).toBe("giteauser");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("preserve strategy: org repos go to same org name", () => {
|
||||||
|
const repo = { ...baseRepo, organization: "myorg" };
|
||||||
|
const result = getGiteaRepoOwner({ config: baseConfig, repository: repo });
|
||||||
|
expect(result).toBe("myorg");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("mixed strategy: personal repos go to organization", () => {
|
||||||
|
const configWithMixed = {
|
||||||
|
...baseConfig,
|
||||||
|
giteaConfig: {
|
||||||
|
...baseConfig.giteaConfig!,
|
||||||
|
mirrorStrategy: "mixed" as const,
|
||||||
|
organization: "github-mirrors"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const repo = { ...baseRepo, organization: undefined };
|
||||||
|
const result = getGiteaRepoOwner({ config: configWithMixed, repository: repo });
|
||||||
|
expect(result).toBe("github-mirrors");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("mixed strategy: org repos preserve their structure", () => {
|
||||||
|
const configWithMixed = {
|
||||||
|
...baseConfig,
|
||||||
|
giteaConfig: {
|
||||||
|
...baseConfig.giteaConfig!,
|
||||||
|
mirrorStrategy: "mixed" as const,
|
||||||
|
organization: "github-mirrors"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const repo = { ...baseRepo, organization: "myorg" };
|
||||||
|
const result = getGiteaRepoOwner({ config: configWithMixed, repository: repo });
|
||||||
|
expect(result).toBe("myorg");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("mixed strategy: fallback to username if no org configs", () => {
|
||||||
|
const configWithMixed = {
|
||||||
|
...baseConfig,
|
||||||
|
giteaConfig: {
|
||||||
|
...baseConfig.giteaConfig!,
|
||||||
|
mirrorStrategy: "mixed" as const,
|
||||||
|
organization: undefined,
|
||||||
|
personalReposOrg: undefined
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const repo = { ...baseRepo, organization: undefined };
|
||||||
|
const result = getGiteaRepoOwner({ config: configWithMixed, repository: repo });
|
||||||
|
expect(result).toBe("giteauser");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
194
src/lib/gitea.ts
194
src/lib/gitea.ts
@@ -9,7 +9,87 @@ import type { Organization, Repository } from "./db/schema";
|
|||||||
import { httpPost, httpGet } from "./http-client";
|
import { httpPost, httpGet } from "./http-client";
|
||||||
import { createMirrorJob } from "./helpers";
|
import { createMirrorJob } from "./helpers";
|
||||||
import { db, organizations, repositories } from "./db";
|
import { db, organizations, repositories } from "./db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get organization configuration including destination override
|
||||||
|
*/
|
||||||
|
export const getOrganizationConfig = async ({
|
||||||
|
orgName,
|
||||||
|
userId,
|
||||||
|
}: {
|
||||||
|
orgName: string;
|
||||||
|
userId: string;
|
||||||
|
}): Promise<Organization | null> => {
|
||||||
|
try {
|
||||||
|
const [orgConfig] = await db
|
||||||
|
.select()
|
||||||
|
.from(organizations)
|
||||||
|
.where(and(eq(organizations.name, orgName), eq(organizations.userId, userId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
return orgConfig || null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error fetching organization config for ${orgName}:`, error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enhanced async version of getGiteaRepoOwner that supports organization overrides
|
||||||
|
*/
|
||||||
|
export const getGiteaRepoOwnerAsync = async ({
|
||||||
|
config,
|
||||||
|
repository,
|
||||||
|
}: {
|
||||||
|
config: Partial<Config>;
|
||||||
|
repository: Repository;
|
||||||
|
}): Promise<string> => {
|
||||||
|
if (!config.githubConfig || !config.giteaConfig) {
|
||||||
|
throw new Error("GitHub or Gitea config is required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.giteaConfig.username) {
|
||||||
|
throw new Error("Gitea username is required.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!config.userId) {
|
||||||
|
throw new Error("User ID is required for organization overrides.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if repository is starred - starred repos always go to starredReposOrg (highest priority)
|
||||||
|
if (repository.isStarred && config.giteaConfig.starredReposOrg) {
|
||||||
|
return config.giteaConfig.starredReposOrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for repository-specific override (second highest priority)
|
||||||
|
if (repository.destinationOrg) {
|
||||||
|
console.log(`Using repository override: ${repository.fullName} -> ${repository.destinationOrg}`);
|
||||||
|
return repository.destinationOrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for organization-specific override
|
||||||
|
if (repository.organization) {
|
||||||
|
const orgConfig = await getOrganizationConfig({
|
||||||
|
orgName: repository.organization,
|
||||||
|
userId: config.userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (orgConfig?.destinationOrg) {
|
||||||
|
console.log(`Using organization override: ${repository.organization} -> ${orgConfig.destinationOrg}`);
|
||||||
|
return orgConfig.destinationOrg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for personal repos override (when it's user's repo, not an organization)
|
||||||
|
if (!repository.organization && config.giteaConfig.personalReposOrg) {
|
||||||
|
console.log(`Using personal repos override: ${config.giteaConfig.personalReposOrg}`);
|
||||||
|
return config.giteaConfig.personalReposOrg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to existing strategy logic
|
||||||
|
return getGiteaRepoOwner({ config, repository });
|
||||||
|
};
|
||||||
|
|
||||||
export const getGiteaRepoOwner = ({
|
export const getGiteaRepoOwner = ({
|
||||||
config,
|
config,
|
||||||
@@ -37,11 +117,12 @@ export const getGiteaRepoOwner = ({
|
|||||||
|
|
||||||
switch (mirrorStrategy) {
|
switch (mirrorStrategy) {
|
||||||
case "preserve":
|
case "preserve":
|
||||||
// Keep GitHub structure - org repos go to same org, personal repos to user
|
// Keep GitHub structure - org repos go to same org, personal repos to user (or override)
|
||||||
if (repository.organization) {
|
if (repository.organization) {
|
||||||
return repository.organization;
|
return repository.organization;
|
||||||
}
|
}
|
||||||
return config.giteaConfig.username;
|
// Use personal repos override if configured, otherwise use username
|
||||||
|
return config.giteaConfig.personalReposOrg || config.giteaConfig.username;
|
||||||
|
|
||||||
case "single-org":
|
case "single-org":
|
||||||
// All non-starred repos go to the destination organization
|
// All non-starred repos go to the destination organization
|
||||||
@@ -55,6 +136,19 @@ export const getGiteaRepoOwner = ({
|
|||||||
// All non-starred repos go under the user account
|
// All non-starred repos go under the user account
|
||||||
return config.giteaConfig.username;
|
return config.giteaConfig.username;
|
||||||
|
|
||||||
|
case "mixed":
|
||||||
|
// Mixed mode: personal repos to single org, organization repos preserve structure
|
||||||
|
if (repository.organization) {
|
||||||
|
// Organization repos preserve their structure
|
||||||
|
return repository.organization;
|
||||||
|
}
|
||||||
|
// Personal repos go to configured organization (same as single-org)
|
||||||
|
if (config.giteaConfig.organization) {
|
||||||
|
return config.giteaConfig.organization;
|
||||||
|
}
|
||||||
|
// Fallback to username if no organization specified
|
||||||
|
return config.giteaConfig.username;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Default fallback
|
// Default fallback
|
||||||
return config.giteaConfig.username;
|
return config.giteaConfig.username;
|
||||||
@@ -160,15 +254,18 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
throw new Error("Gitea username is required.");
|
throw new Error("Gitea username is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the correct owner based on the strategy (with organization overrides)
|
||||||
|
const repoOwner = await getGiteaRepoOwnerAsync({ config, repository });
|
||||||
|
|
||||||
const isExisting = await isRepoPresentInGitea({
|
const isExisting = await isRepoPresentInGitea({
|
||||||
config,
|
config,
|
||||||
owner: config.giteaConfig.username,
|
owner: repoOwner,
|
||||||
repoName: repository.name,
|
repoName: repository.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isExisting) {
|
if (isExisting) {
|
||||||
console.log(
|
console.log(
|
||||||
`Repository ${repository.name} already exists in Gitea. Updating database status.`
|
`Repository ${repository.name} already exists in Gitea under ${repoOwner}. Updating database status.`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update database to reflect that the repository is already mirrored
|
// Update database to reflect that the repository is already mirrored
|
||||||
@@ -179,7 +276,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastMirrored: new Date(),
|
lastMirrored: new Date(),
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
mirroredLocation: `${config.giteaConfig.username}/${repository.name}`,
|
mirroredLocation: `${repoOwner}/${repository.name}`,
|
||||||
})
|
})
|
||||||
.where(eq(repositories.id, repository.id!));
|
.where(eq(repositories.id, repository.id!));
|
||||||
|
|
||||||
@@ -189,7 +286,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
repositoryId: repository.id,
|
repositoryId: repository.id,
|
||||||
repositoryName: repository.name,
|
repositoryName: repository.name,
|
||||||
message: `Repository ${repository.name} already exists in Gitea`,
|
message: `Repository ${repository.name} already exists in Gitea`,
|
||||||
details: `Repository ${repository.name} was found to already exist in Gitea and database status was updated.`,
|
details: `Repository ${repository.name} was found to already exist in Gitea under ${repoOwner} and database status was updated.`,
|
||||||
status: "mirrored",
|
status: "mirrored",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -238,6 +335,15 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
|
|
||||||
const apiUrl = `${config.giteaConfig.url}/api/v1/repos/migrate`;
|
const apiUrl = `${config.giteaConfig.url}/api/v1/repos/migrate`;
|
||||||
|
|
||||||
|
// Handle organization creation if needed for single-org or preserve strategies
|
||||||
|
if (repoOwner !== config.giteaConfig.username && !repository.isStarred) {
|
||||||
|
// Need to create the organization if it doesn't exist
|
||||||
|
await getOrCreateGiteaOrg({
|
||||||
|
orgName: repoOwner,
|
||||||
|
config,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const response = await httpPost(
|
const response = await httpPost(
|
||||||
apiUrl,
|
apiUrl,
|
||||||
{
|
{
|
||||||
@@ -246,7 +352,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
mirror: true,
|
mirror: true,
|
||||||
wiki: config.githubConfig.mirrorWiki || false, // will mirror wiki if it exists
|
wiki: config.githubConfig.mirrorWiki || false, // will mirror wiki if it exists
|
||||||
private: repository.isPrivate,
|
private: repository.isPrivate,
|
||||||
repo_owner: config.giteaConfig.username,
|
repo_owner: repoOwner,
|
||||||
description: "",
|
description: "",
|
||||||
service: "git",
|
service: "git",
|
||||||
},
|
},
|
||||||
@@ -286,7 +392,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastMirrored: new Date(),
|
lastMirrored: new Date(),
|
||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
mirroredLocation: `${config.giteaConfig.username}/${repository.name}`,
|
mirroredLocation: `${repoOwner}/${repository.name}`,
|
||||||
})
|
})
|
||||||
.where(eq(repositories.id, repository.id!));
|
.where(eq(repositories.id, repository.id!));
|
||||||
|
|
||||||
@@ -763,11 +869,37 @@ export async function mirrorGitHubOrgToGitea({
|
|||||||
status: repoStatusEnum.parse("mirroring"),
|
status: repoStatusEnum.parse("mirroring"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const giteaOrgId = await getOrCreateGiteaOrg({
|
// Get the mirror strategy - use preserveOrgStructure for backward compatibility
|
||||||
orgId: organization.id,
|
const mirrorStrategy = config.giteaConfig?.mirrorStrategy ||
|
||||||
orgName: organization.name,
|
(config.githubConfig?.preserveOrgStructure ? "preserve" : "flat-user");
|
||||||
config,
|
|
||||||
});
|
let giteaOrgId: number;
|
||||||
|
let targetOrgName: string;
|
||||||
|
|
||||||
|
// Determine the target organization based on strategy
|
||||||
|
if (mirrorStrategy === "single-org" && config.giteaConfig?.organization) {
|
||||||
|
// For single-org strategy, use the configured destination organization
|
||||||
|
targetOrgName = config.giteaConfig.organization;
|
||||||
|
giteaOrgId = await getOrCreateGiteaOrg({
|
||||||
|
orgId: organization.id,
|
||||||
|
orgName: targetOrgName,
|
||||||
|
config,
|
||||||
|
});
|
||||||
|
console.log(`Using single organization strategy: all repos will go to ${targetOrgName}`);
|
||||||
|
} else if (mirrorStrategy === "preserve") {
|
||||||
|
// For preserve strategy, create/use an org with the same name as GitHub
|
||||||
|
targetOrgName = organization.name;
|
||||||
|
giteaOrgId = await getOrCreateGiteaOrg({
|
||||||
|
orgId: organization.id,
|
||||||
|
orgName: targetOrgName,
|
||||||
|
config,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// For flat-user strategy, we shouldn't create organizations at all
|
||||||
|
// Skip organization creation and let individual repos be handled by getGiteaRepoOwner
|
||||||
|
console.log(`Using flat-user strategy: repos will be placed under user account`);
|
||||||
|
targetOrgName = config.giteaConfig?.username || "";
|
||||||
|
}
|
||||||
|
|
||||||
//query the db with the org name and get the repos
|
//query the db with the org name and get the repos
|
||||||
const orgRepos = await db
|
const orgRepos = await db
|
||||||
@@ -805,17 +937,27 @@ export async function mirrorGitHubOrgToGitea({
|
|||||||
|
|
||||||
// Log the start of mirroring
|
// Log the start of mirroring
|
||||||
console.log(
|
console.log(
|
||||||
`Starting mirror for repository: ${repo.name} in organization ${organization.name}`
|
`Starting mirror for repository: ${repo.name} from GitHub org ${organization.name}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mirror the repository
|
// Mirror the repository based on strategy
|
||||||
await mirrorGitHubRepoToGiteaOrg({
|
if (mirrorStrategy === "flat-user") {
|
||||||
octokit,
|
// For flat-user strategy, mirror directly to user account
|
||||||
config,
|
await mirrorGithubRepoToGitea({
|
||||||
repository: repoData,
|
octokit,
|
||||||
giteaOrgId,
|
repository: repoData,
|
||||||
orgName: organization.name,
|
config,
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// For preserve and single-org strategies, use organization
|
||||||
|
await mirrorGitHubRepoToGiteaOrg({
|
||||||
|
octokit,
|
||||||
|
config,
|
||||||
|
repository: repoData,
|
||||||
|
giteaOrgId: giteaOrgId!,
|
||||||
|
orgName: targetOrgName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
},
|
},
|
||||||
@@ -939,8 +1081,8 @@ export const syncGiteaRepo = async ({
|
|||||||
status: repoStatusEnum.parse("syncing"),
|
status: repoStatusEnum.parse("syncing"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the expected owner based on current config
|
// Get the expected owner based on current config (with organization overrides)
|
||||||
const repoOwner = getGiteaRepoOwner({ config, repository });
|
const repoOwner = await getGiteaRepoOwnerAsync({ config, repository });
|
||||||
|
|
||||||
// Check if repo exists at the expected location or alternate location
|
// Check if repo exists at the expected location or alternate location
|
||||||
const { present, actualOwner } = await checkRepoLocation({
|
const { present, actualOwner } = await checkRepoLocation({
|
||||||
@@ -1241,7 +1383,7 @@ export async function mirrorGitHubReleasesToGitea({
|
|||||||
throw new Error("Gitea config is incomplete for mirroring releases.");
|
throw new Error("Gitea config is incomplete for mirroring releases.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const repoOwner = getGiteaRepoOwner({
|
const repoOwner = await getGiteaRepoOwnerAsync({
|
||||||
config,
|
config,
|
||||||
repository,
|
repository,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ interface DbGiteaConfig {
|
|||||||
visibility: "public" | "private" | "limited";
|
visibility: "public" | "private" | "limited";
|
||||||
starredReposOrg: string;
|
starredReposOrg: string;
|
||||||
preserveOrgStructure: boolean;
|
preserveOrgStructure: boolean;
|
||||||
mirrorStrategy?: "preserve" | "single-org" | "flat-user";
|
mirrorStrategy?: "preserve" | "single-org" | "flat-user" | "mixed";
|
||||||
|
personalReposOrg?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,6 +107,7 @@ export function mapDbToUiConfig(dbConfig: any): {
|
|||||||
starredReposOrg: dbConfig.giteaConfig?.starredReposOrg || "github",
|
starredReposOrg: dbConfig.giteaConfig?.starredReposOrg || "github",
|
||||||
preserveOrgStructure: dbConfig.giteaConfig?.preserveOrgStructure || false,
|
preserveOrgStructure: dbConfig.giteaConfig?.preserveOrgStructure || false,
|
||||||
mirrorStrategy: dbConfig.giteaConfig?.mirrorStrategy,
|
mirrorStrategy: dbConfig.giteaConfig?.mirrorStrategy,
|
||||||
|
personalReposOrg: dbConfig.giteaConfig?.personalReposOrg,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mirrorOptions: MirrorOptions = {
|
const mirrorOptions: MirrorOptions = {
|
||||||
|
|||||||
37
src/pages/404.astro
Normal file
37
src/pages/404.astro
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
import '../styles/global.css';
|
||||||
|
import ThemeScript from '@/components/theme/ThemeScript.astro';
|
||||||
|
import { NotFound } from '@/components/NotFound';
|
||||||
|
|
||||||
|
const generator = Astro.generator;
|
||||||
|
---
|
||||||
|
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
|
<meta name="generator" content={generator} />
|
||||||
|
<title>Page Not Found - Gitea Mirror</title>
|
||||||
|
<ThemeScript />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<NotFound client:load />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
/* Floating animation for 404 text */
|
||||||
|
:global(.animate-float) {
|
||||||
|
animation: float 3s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes float {
|
||||||
|
0%, 100% {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
transform: translateY(-10px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -208,7 +208,7 @@ async function checkLatestVersion(): Promise<string> {
|
|||||||
try {
|
try {
|
||||||
// Fetch the latest release from GitHub
|
// Fetch the latest release from GitHub
|
||||||
const response = await httpGet(
|
const response = await httpGet(
|
||||||
'https://api.github.com/repos/arunavo4/gitea-mirror/releases/latest',
|
'https://api.github.com/repos/RayLabsHQ/gitea-mirror/releases/latest',
|
||||||
{ 'Accept': 'application/vnd.github.v3+json' }
|
{ 'Accept': 'application/vnd.github.v3+json' }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { repositoryVisibilityEnum, repoStatusEnum } from "@/types/Repository";
|
|||||||
import {
|
import {
|
||||||
mirrorGithubRepoToGitea,
|
mirrorGithubRepoToGitea,
|
||||||
mirrorGitHubOrgRepoToGiteaOrg,
|
mirrorGitHubOrgRepoToGiteaOrg,
|
||||||
getGiteaRepoOwner,
|
getGiteaRepoOwnerAsync,
|
||||||
} from "@/lib/gitea";
|
} from "@/lib/gitea";
|
||||||
import { createGitHubClient } from "@/lib/github";
|
import { createGitHubClient } from "@/lib/github";
|
||||||
import { processWithResilience } from "@/lib/utils/concurrency";
|
import { processWithResilience } from "@/lib/utils/concurrency";
|
||||||
@@ -97,8 +97,8 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
// Log the start of mirroring
|
// Log the start of mirroring
|
||||||
console.log(`Starting mirror for repository: ${repo.name}`);
|
console.log(`Starting mirror for repository: ${repo.name}`);
|
||||||
|
|
||||||
// Determine where the repository should be mirrored
|
// Determine where the repository should be mirrored (with organization overrides)
|
||||||
const owner = getGiteaRepoOwner({
|
const owner = await getGiteaRepoOwnerAsync({
|
||||||
config,
|
config,
|
||||||
repository: repoData,
|
repository: repoData,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { db, configs, repositories } from "@/lib/db";
|
import { db, configs, repositories } from "@/lib/db";
|
||||||
import { eq, inArray } from "drizzle-orm";
|
import { eq, inArray } from "drizzle-orm";
|
||||||
import { getGiteaRepoOwner, isRepoPresentInGitea } from "@/lib/gitea";
|
import { getGiteaRepoOwnerAsync, isRepoPresentInGitea } from "@/lib/gitea";
|
||||||
import {
|
import {
|
||||||
mirrorGithubRepoToGitea,
|
mirrorGithubRepoToGitea,
|
||||||
mirrorGitHubOrgRepoToGiteaOrg,
|
mirrorGitHubOrgRepoToGiteaOrg,
|
||||||
@@ -109,8 +109,8 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
status: "imported",
|
status: "imported",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Determine if the repository exists in Gitea
|
// Determine if the repository exists in Gitea (with organization overrides)
|
||||||
let owner = getGiteaRepoOwner({
|
let owner = await getGiteaRepoOwnerAsync({
|
||||||
config,
|
config,
|
||||||
repository: repoData,
|
repository: repoData,
|
||||||
});
|
});
|
||||||
|
|||||||
82
src/pages/api/organizations/[id].ts
Normal file
82
src/pages/api/organizations/[id].ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import type { APIRoute } from "astro";
|
||||||
|
import { db, organizations } from "@/lib/db";
|
||||||
|
import { eq, and } from "drizzle-orm";
|
||||||
|
import { createSecureErrorResponse } from "@/lib/utils";
|
||||||
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
const JWT_SECRET = process.env.JWT_SECRET || "your-secret-key";
|
||||||
|
|
||||||
|
export const PATCH: APIRoute = async ({ request, params, cookies }) => {
|
||||||
|
try {
|
||||||
|
// Get token from Authorization header or cookies
|
||||||
|
const authHeader = request.headers.get("Authorization");
|
||||||
|
const token = authHeader?.split(" ")[1] || cookies.get("token")?.value;
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify token and get user ID
|
||||||
|
let userId: string;
|
||||||
|
try {
|
||||||
|
const decoded = jwt.verify(token, JWT_SECRET) as { id: string };
|
||||||
|
userId = decoded.id;
|
||||||
|
} catch (error) {
|
||||||
|
return new Response(JSON.stringify({ error: "Invalid token" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const orgId = params.id;
|
||||||
|
if (!orgId) {
|
||||||
|
return new Response(JSON.stringify({ error: "Organization ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await request.json();
|
||||||
|
const { destinationOrg } = body;
|
||||||
|
|
||||||
|
// Validate that the organization belongs to the user
|
||||||
|
const [existingOrg] = await db
|
||||||
|
.select()
|
||||||
|
.from(organizations)
|
||||||
|
.where(and(eq(organizations.id, orgId), eq(organizations.userId, userId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!existingOrg) {
|
||||||
|
return new Response(JSON.stringify({ error: "Organization not found" }), {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the organization's destination override
|
||||||
|
await db
|
||||||
|
.update(organizations)
|
||||||
|
.set({
|
||||||
|
destinationOrg: destinationOrg || null,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
})
|
||||||
|
.where(eq(organizations.id, orgId));
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
success: true,
|
||||||
|
message: "Organization destination updated successfully",
|
||||||
|
destinationOrg: destinationOrg || null,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return createSecureErrorResponse(error, "Update organization destination", 500);
|
||||||
|
}
|
||||||
|
};
|
||||||
82
src/pages/api/repositories/[id].ts
Normal file
82
src/pages/api/repositories/[id].ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import type { APIRoute } from "astro";
|
||||||
|
import { db, repositories } from "@/lib/db";
|
||||||
|
import { eq, and } from "drizzle-orm";
|
||||||
|
import { createSecureErrorResponse } from "@/lib/utils";
|
||||||
|
import jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
const JWT_SECRET = process.env.JWT_SECRET || "your-secret-key";
|
||||||
|
|
||||||
|
export const PATCH: APIRoute = async ({ request, params, cookies }) => {
|
||||||
|
try {
|
||||||
|
// Get token from Authorization header or cookies
|
||||||
|
const authHeader = request.headers.get("Authorization");
|
||||||
|
const token = authHeader?.split(" ")[1] || cookies.get("token")?.value;
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify token and get user ID
|
||||||
|
let userId: string;
|
||||||
|
try {
|
||||||
|
const decoded = jwt.verify(token, JWT_SECRET) as { id: string };
|
||||||
|
userId = decoded.id;
|
||||||
|
} catch (error) {
|
||||||
|
return new Response(JSON.stringify({ error: "Invalid token" }), {
|
||||||
|
status: 401,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const repoId = params.id;
|
||||||
|
if (!repoId) {
|
||||||
|
return new Response(JSON.stringify({ error: "Repository ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await request.json();
|
||||||
|
const { destinationOrg } = body;
|
||||||
|
|
||||||
|
// Validate that the repository belongs to the user
|
||||||
|
const [existingRepo] = await db
|
||||||
|
.select()
|
||||||
|
.from(repositories)
|
||||||
|
.where(and(eq(repositories.id, repoId), eq(repositories.userId, userId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!existingRepo) {
|
||||||
|
return new Response(JSON.stringify({ error: "Repository not found" }), {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the repository's destination override
|
||||||
|
await db
|
||||||
|
.update(repositories)
|
||||||
|
.set({
|
||||||
|
destinationOrg: destinationOrg || null,
|
||||||
|
updatedAt: new Date(),
|
||||||
|
})
|
||||||
|
.where(eq(repositories.id, repoId));
|
||||||
|
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
success: true,
|
||||||
|
message: "Repository destination updated successfully",
|
||||||
|
destinationOrg: destinationOrg || null,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return createSecureErrorResponse(error, "Update repository destination", 500);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -85,7 +85,7 @@ import MainLayout from '../../layouts/main.astro';
|
|||||||
|
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
{[
|
{[
|
||||||
{ step: 'Clone the repository', cmd: 'git clone https://github.com/arunavo4/gitea-mirror.git\ncd gitea-mirror' },
|
{ step: 'Clone the repository', cmd: 'git clone https://github.com/RayLabsHQ/gitea-mirror.git\ncd gitea-mirror' },
|
||||||
{ step: 'Start the application in production mode', cmd: 'docker compose up -d' },
|
{ step: 'Start the application in production mode', cmd: 'docker compose up -d' },
|
||||||
{ step: 'Access the application', cmd: null, text: 'Open your browser and navigate to <a href="http://localhost:4321" class="text-primary hover:underline font-medium">http://localhost:4321</a>' }
|
{ step: 'Access the application', cmd: null, text: 'Open your browser and navigate to <a href="http://localhost:4321" class="text-primary hover:underline font-medium">http://localhost:4321</a>' }
|
||||||
].map((item, i) => (
|
].map((item, i) => (
|
||||||
@@ -123,7 +123,7 @@ import MainLayout from '../../layouts/main.astro';
|
|||||||
<span class="text-sm text-muted-foreground">Clone the repository</span>
|
<span class="text-sm text-muted-foreground">Clone the repository</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-muted/30 rounded-lg p-4">
|
<div class="bg-muted/30 rounded-lg p-4">
|
||||||
<pre class="text-sm"><code>git clone https://github.com/arunavo4/gitea-mirror.git
|
<pre class="text-sm"><code>git clone https://github.com/RayLabsHQ/gitea-mirror.git
|
||||||
cd gitea-mirror</code></pre>
|
cd gitea-mirror</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { type Config as ConfigType } from "@/lib/db/schema";
|
import { type Config as ConfigType } from "@/lib/db/schema";
|
||||||
|
|
||||||
export type GiteaOrgVisibility = "public" | "private" | "limited";
|
export type GiteaOrgVisibility = "public" | "private" | "limited";
|
||||||
export type MirrorStrategy = "preserve" | "single-org" | "flat-user";
|
export type MirrorStrategy = "preserve" | "single-org" | "flat-user" | "mixed";
|
||||||
|
|
||||||
export interface GiteaConfig {
|
export interface GiteaConfig {
|
||||||
url: string;
|
url: string;
|
||||||
@@ -12,6 +12,7 @@ export interface GiteaConfig {
|
|||||||
starredReposOrg: string;
|
starredReposOrg: string;
|
||||||
preserveOrgStructure: boolean;
|
preserveOrgStructure: boolean;
|
||||||
mirrorStrategy?: MirrorStrategy; // New field for the strategy
|
mirrorStrategy?: MirrorStrategy; // New field for the strategy
|
||||||
|
personalReposOrg?: string; // Override destination for personal repos
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ScheduleConfig {
|
export interface ScheduleConfig {
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple test to verify that our security fix is working correctly
|
|
||||||
* This test simulates the original security vulnerability and confirms it's been fixed
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { createSecureErrorResponse } from './src/lib/utils.js';
|
|
||||||
|
|
||||||
console.log('🔒 Testing Security Fix for Information Exposure...\n');
|
|
||||||
|
|
||||||
// Test 1: Sensitive error should be sanitized
|
|
||||||
console.log('Test 1: Sensitive error with file path');
|
|
||||||
const sensitiveError = new Error('ENOENT: no such file or directory, open \'/etc/passwd\'');
|
|
||||||
const response1 = createSecureErrorResponse(sensitiveError, 'test', 500);
|
|
||||||
|
|
||||||
// Parse the response to check what's exposed
|
|
||||||
const responseText1 = await response1.text();
|
|
||||||
const responseData1 = JSON.parse(responseText1);
|
|
||||||
|
|
||||||
console.log('Original error:', sensitiveError.message);
|
|
||||||
console.log('Sanitized response:', responseData1.error);
|
|
||||||
console.log('✅ Sensitive path information hidden:', !responseData1.error.includes('/etc/passwd'));
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
// Test 2: Safe error should be exposed
|
|
||||||
console.log('Test 2: Safe error that should be exposed');
|
|
||||||
const safeError = new Error('Missing required field: userId');
|
|
||||||
const response2 = createSecureErrorResponse(safeError, 'test', 400);
|
|
||||||
|
|
||||||
const responseText2 = await response2.text();
|
|
||||||
const responseData2 = JSON.parse(responseText2);
|
|
||||||
|
|
||||||
console.log('Original error:', safeError.message);
|
|
||||||
console.log('Response:', responseData2.error);
|
|
||||||
console.log('✅ Safe error properly exposed:', responseData2.error === safeError.message);
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
// Test 3: Database connection error should be sanitized
|
|
||||||
console.log('Test 3: Database connection error');
|
|
||||||
const dbError = new Error('Connection failed: sqlite3://localhost:5432/secret_db?password=admin123');
|
|
||||||
const response3 = createSecureErrorResponse(dbError, 'test', 500);
|
|
||||||
|
|
||||||
const responseText3 = await response3.text();
|
|
||||||
const responseData3 = JSON.parse(responseText3);
|
|
||||||
|
|
||||||
console.log('Original error:', dbError.message);
|
|
||||||
console.log('Sanitized response:', responseData3.error);
|
|
||||||
console.log('✅ Database credentials hidden:', !responseData3.error.includes('password=admin123'));
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
// Test 4: Stack trace should not be exposed
|
|
||||||
console.log('Test 4: Stack trace exposure check');
|
|
||||||
const errorWithStack = new Error('Internal server error');
|
|
||||||
errorWithStack.stack = 'Error: Internal server error\n at /home/user/secret/app.js:123:45';
|
|
||||||
const response4 = createSecureErrorResponse(errorWithStack, 'test', 500);
|
|
||||||
|
|
||||||
const responseText4 = await response4.text();
|
|
||||||
const responseData4 = JSON.parse(responseText4);
|
|
||||||
|
|
||||||
console.log('Response keys:', Object.keys(responseData4));
|
|
||||||
console.log('✅ Stack trace not exposed:', !responseData4.hasOwnProperty('stack'));
|
|
||||||
console.log('✅ File paths not exposed:', !responseData4.error.includes('/home/user/secret'));
|
|
||||||
console.log('');
|
|
||||||
|
|
||||||
console.log('🎉 All security tests passed! The vulnerability has been successfully fixed.');
|
|
||||||
console.log('');
|
|
||||||
console.log('Summary of fixes:');
|
|
||||||
console.log('- ✅ Error details are logged server-side for debugging');
|
|
||||||
console.log('- ✅ Only safe, whitelisted error messages are sent to clients');
|
|
||||||
console.log('- ✅ Sensitive information like file paths, credentials, and stack traces are hidden');
|
|
||||||
console.log('- ✅ Generic error message is returned for unsafe errors');
|
|
||||||
console.log('- ✅ Timestamp is included for correlation with server logs');
|
|
||||||
Reference in New Issue
Block a user