diff --git a/alembic/versions/2026_10_06_1400_repository_submodules.py b/alembic/versions/2026_10_06_1400_repository_submodules.py
new file mode 100644
index 00000000..123ba97d
--- /dev/null
+++ b/alembic/versions/2026_10_06_1400_repository_submodules.py
@@ -0,0 +1,22 @@
+"""A git Repo can also download its submodules: repository.submodules.
+
+Revision ID: 2026_10_06_1400
+Revises: 2026_10_06_1300
+"""
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = '2026_10_06_1400'
+down_revision = '2026_10_06_1300'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+ op.add_column('repository', sa.Column('submodules', sa.Boolean(), server_default=sa.false(), nullable=False))
+
+
+def downgrade():
+ with op.batch_alter_table('repository') as batch_op:
+ batch_op.drop_column('submodules')
diff --git a/app/src/api.js b/app/src/api.js
index 216382dd..4b2eaca1 100644
--- a/app/src/api.js
+++ b/app/src/api.js
@@ -2582,3 +2582,17 @@ export async function searchRepos(searchStr, tagNames) {
}
await reposError(response, 'Failed to search repos.');
}
+
+// The commits of a repo's checked out branch, newest first: {commits: [{sha, author, date, message}], total}.
+export async function getRepoLog(repoId, offset = 0, limit = 50) {
+ const response = await apiGet(`${REPOS_API}/${repoId}/log?limit=${limit}&offset=${offset}`);
+ if (response.ok) {
+ return await response.json();
+ }
+ await reposError(response, 'Failed to fetch the repo history.');
+}
+
+// A ZIP of a repo's checked out files; the browser downloads it.
+export function repoArchiveURL(repoId) {
+ return `${REPOS_API}/${repoId}/archive.zip`;
+}
diff --git a/app/src/components/Repos.js b/app/src/components/Repos.js
index d604090e..d8c0bade 100644
--- a/app/src/components/Repos.js
+++ b/app/src/components/Repos.js
@@ -4,6 +4,7 @@ import {IconBrandGit, IconFile, IconFolder, IconGitBranch, IconGitCommit} from "
import {
Anchor,
Button,
+ ButtonGroup,
Checkbox,
Grid,
Group,
@@ -42,7 +43,9 @@ import {
getCollectionTagInfo,
getFile,
getRepo,
+ getRepoLog,
getRepoTree,
+ repoArchiveURL,
tagCollection,
updateRepo,
updateRepoNow,
@@ -364,12 +367,90 @@ export function RepoReadme({repo, readmePath}) {
;
}
+/** A page of a repo's commits, newest first. */
+export function RepoHistoryTable({commits}) {
+ return
+
+ {commits.map(commit =>
+ {commit.sha.slice(0, 7)}
+
+ {commit.message}
+ {commit.author}
+
+
+ {isoDatetimeToAgoPopup(commit.date)}
+
+ )}
+
+
;
+}
+
+const HISTORY_PAGE_SIZE = 50;
+
+/** A repo's commits, a page at a time. */
+export function RepoHistory({repo}) {
+ const [commits, setCommits] = useState(null); // null=loading, undefined=error
+ const [total, setTotal] = useState(0);
+ const [loadingMore, setLoadingMore] = useState(false);
+
+ const fetchPage = async (offset) => {
+ const log = await getRepoLog(repo.id, offset, HISTORY_PAGE_SIZE);
+ setTotal(log.total);
+ return log.commits;
+ };
+
+ useEffect(() => {
+ let current = true;
+ setCommits(null);
+ fetchPage(0)
+ .then(page => current && setCommits(page))
+ .catch(e => {
+ console.error(e);
+ if (current) setCommits(undefined);
+ });
+ return () => {
+ current = false;
+ };
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [repo.id, repo.head_sha]);
+
+ if (commits === undefined) {
+ return Could not fetch the repo's history;
+ }
+ if (commits === null) {
+ return ;
+ }
+
+ const loadMore = async () => {
+ setLoadingMore(true);
+ try {
+ const page = await fetchPage(commits.length);
+ setCommits([...commits, ...page]);
+ } catch (e) {
+ console.error(e);
+ } finally {
+ setLoadingMore(false);
+ }
+ };
+
+ return
+ {total === 1 ? '1 commit' : `${total} commits`}
+ {repo.mode === 'snapshot' &&
+ A snapshot only keeps the latest commit. Change the repo's mode to Full history to keep all of them.
+
}
+
+ {commits.length < total && }
+ ;
+}
+
export function RepoViewPage() {
const {repoId} = useParams();
const {repo, refetch} = useRepo(repoId);
const [path, setPath] = useOneQuery('path');
+ const [view, setView] = useOneQuery('view');
const {setPreviewFile} = useContext(FilePreviewContext);
- const tree = useRepoTree(repoId, path || '', !!repo?.head_sha);
+ // The files are only listed when they are shown.
+ const tree = useRepoTree(repoId, path || '', !!repo?.head_sha && view !== 'history');
useTitle(repo?.name ? `${repo.name} Repo` : 'Repo');
@@ -393,8 +474,11 @@ export function RepoViewPage() {
}
};
+ const showHistory = view === 'history';
let files = null;
- if (repo.head_sha) {
+ if (repo.head_sha && showHistory) {
+ files = ;
+ } else if (repo.head_sha) {
if (tree === undefined) {
files = Could not list the repo's files;
} else if (tree === null) {
@@ -416,8 +500,19 @@ export function RepoViewPage() {
Update Now
+ {repo.head_sha && }
+ {repo.head_sha &&
+
+
+ }
{files}
>;
}
@@ -442,6 +537,7 @@ export function RepoNewPage() {
const [frequency, setFrequency] = useState(String(weeklyOption.value));
const [mode, setMode] = useState('full');
const [branch, setBranch] = useState('');
+ const [submodules, setSubmodules] = useState(false);
const [description, setDescription] = useState('');
const [submitting, setSubmitting] = useState(false);
@@ -459,6 +555,7 @@ export function RepoNewPage() {
frequency: parseInt(frequency),
mode,
branch: branch.trim() || null,
+ submodules,
description: description.trim() || null,
});
toast({type: 'success', title: 'Repo added', description: repo.name, time: 3000});
@@ -512,7 +609,8 @@ export function RepoNewPage() {
/>
+ setMode={setMode} branch={branch} setBranch={setBranch}
+ submodules={submodules} setSubmodules={setSubmodules}/>