=> {
const tagName = nameState;
- const commitId = baseCommitIdState;
+ const baseCommitId = baseCommitIdState;
props.logger.log({
level: Level.RUNNING,
message: props.trans.__('Creating tag…')
});
try {
- await props.model.setTag(tagName, commitId);
+ await props.model.setTag(tagName, baseCommitId);
} catch (err) {
setErrorState(err.message.replace(/^fatal:/, ''));
props.logger.log({
diff --git a/src/components/PastCommitNode.tsx b/src/components/PastCommitNode.tsx
index 15b3cac2f..5183dbf0f 100644
--- a/src/components/PastCommitNode.tsx
+++ b/src/components/PastCommitNode.tsx
@@ -42,6 +42,11 @@ export interface IPastCommitNodeProps {
*/
branches: Git.IBranch[];
+ /**
+ * List of tags.
+ */
+ tagsList: Git.ITag[];
+
/**
* Extension data model.
*/
@@ -199,6 +204,7 @@ export class PastCommitNode extends React.Component<
)}
{this._renderBranches()}
+ {this._renderTags()}
{this.props.commit.commit_msg}
{this.props.expanded && this.props.children}
@@ -250,6 +256,39 @@ export class PastCommitNode extends React.Component<
);
}
+ /**
+ * Renders tags information.
+ *
+ * @returns array of React elements
+ */
+ private _renderTags(): React.ReactElement[] {
+ const curr = this.props.commit.commit;
+ const tags: Git.ITag[] = [];
+ for (let i = 0; i < this.props.tagsList.length; i++) {
+ const tag = this.props.tagsList[i];
+ if (tag.baseCommitId && tag.baseCommitId === curr) {
+ tags.push(tag);
+ }
+ }
+ return tags.map(this._renderTag, this);
+ }
+
+ /**
+ * Renders individual tag data.
+ *
+ * @param tag - tag data
+ * @returns React element
+ */
+ private _renderTag(tag: Git.ITag): React.ReactElement {
+ return (
+
+
+ {tag.name}
+
+
+ );
+ }
+
/**
* Callback invoked upon clicking on an individual commit.
*
diff --git a/src/components/TagMenu.tsx b/src/components/TagMenu.tsx
index e03396d88..3972c354a 100644
--- a/src/components/TagMenu.tsx
+++ b/src/components/TagMenu.tsx
@@ -91,7 +91,7 @@ export interface ITagMenuProps {
/**
* Current list of tags.
*/
- tagsList: string[];
+ tagsList: Git.ITag[];
/**
* Boolean indicating whether branching is disabled.
@@ -215,7 +215,7 @@ export class TagMenu extends React.Component {
// Perform a "simple" filter... (TODO: consider implementing fuzzy filtering)
const filter = this.state.filter;
const tags = this.props.tagsList.filter(
- tag => !filter || tag.includes(filter)
+ tag => !filter || tag.name.includes(filter)
);
return (
{
)}
itemCount={tags.length}
itemData={tags}
- itemKey={(index, data) => data[index]}
+ itemKey={(index, data) => data[index].name}
itemSize={ITEM_HEIGHT}
style={{ overflowX: 'hidden', paddingTop: 0, paddingBottom: 0 }}
width={'auto'}
@@ -243,18 +243,18 @@ export class TagMenu extends React.Component {
*/
private _renderItem = (props: ListChildComponentProps): JSX.Element => {
const { data, index, style } = props;
- const tag = data[index] as string;
+ const tag = data[index] as Git.ITag;
return (
- {tag}
+ {tag.name}
);
};
diff --git a/src/components/Toolbar.tsx b/src/components/Toolbar.tsx
index 18715a3d8..0180b9e3f 100644
--- a/src/components/Toolbar.tsx
+++ b/src/components/Toolbar.tsx
@@ -48,7 +48,7 @@ export interface IToolbarProps {
/**
* Current list of tags.
*/
- tagsList: string[];
+ tagsList: Git.ITag[];
/**
* Boolean indicating whether branching is disabled.
diff --git a/src/model.ts b/src/model.ts
index 9620bd486..4358c08b8 100644
--- a/src/model.ts
+++ b/src/model.ts
@@ -90,7 +90,7 @@ export class GitExtension implements IGitExtension {
/**
* Tags list for the current repository.
*/
- get tagsList(): string[] {
+ get tagsList(): Git.ITag[] {
return this._tagsList;
}
@@ -1784,7 +1784,7 @@ export class GitExtension implements IGitExtension {
}
/**
- * Retrieve the list of tags in the repository.
+ * Retrieve the list of tags in the repository, with the respective commits they point to.
*
* @returns promise which resolves upon retrieving the tag list
*
@@ -1845,7 +1845,7 @@ export class GitExtension implements IGitExtension {
async setTag(tag: string, commitId: string): Promise {
const path = await this._getPathRepository();
await this._taskHandler.execute('git:tag:create', async () => {
- return await requestAPI(URLExt.join(path, 'new_tag'), 'POST', {
+ return await requestAPI(URLExt.join(path, 'tag'), 'POST', {
tag_id: tag,
commit_id: commitId
});
@@ -2195,7 +2195,7 @@ export class GitExtension implements IGitExtension {
private _stash: Git.IStash;
private _pathRepository: string | null = null;
private _branches: Git.IBranch[] = [];
- private _tagsList: string[] = [];
+ private _tagsList: Git.ITag[] = [];
private _currentBranch: Git.IBranch | null = null;
private _docmanager: IDocumentManager | null;
private _docRegistry: DocumentRegistry | null;
diff --git a/src/tokens.ts b/src/tokens.ts
index 551ab4bf4..467d4fd96 100644
--- a/src/tokens.ts
+++ b/src/tokens.ts
@@ -22,7 +22,7 @@ export interface IGitExtension extends IDisposable {
/**
* The list of tags in the current repo
*/
- tagsList: string[];
+ tagsList: Git.ITag[];
/**
* The current branch
@@ -1259,7 +1259,15 @@ export namespace Git {
export interface ITagResult {
code: number;
message?: string;
- tags?: string[];
+ tags?: ITag[];
+ }
+
+ /**
+ * Tag description interface
+ */
+ export interface ITag {
+ name: string;
+ baseCommitId?: string;
}
/**