diff --git a/Makefile b/Makefile index eea2ac925..0f20967b9 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,12 @@ endif # Used for semver bumping PROTECTED_BRANCH := master APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`) -CURRENT_VERSION := $(shell git describe --abbrev=0 --tags) +CURRENT_VERSION := $(strip $(shell git describe --abbrev=0 --tags)) +LATEST_RELEASE_TAG_RAW := $(shell git tag -l "v*" --sort=-v:refname | grep -v '\-rc' | head -n 1 || true) +LATEST_RELEASE_TAG := $(strip $(LATEST_RELEASE_TAG_RAW)) +ifeq ($(LATEST_RELEASE_TAG),) +LATEST_RELEASE_TAG := $(CURRENT_VERSION) +endif VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION)))) MAJOR := $(word 1,$(VERSION_PARTS)) MINOR := $(word 2,$(VERSION_PARTS)) @@ -81,6 +86,11 @@ endef patch: ## to bump patch version (semver) $(call check_protected_branch) $(call check_pending_pulls) + @$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG))) + @$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION))))) + @$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS))) + @$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS))) + @$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS))) @$(eval PATCH := $(shell echo $$(($(PATCH)+1)))) $(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH)) @echo Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH) @@ -91,6 +101,11 @@ patch: ## to bump patch version (semver) minor: ## to bump minor version (semver) $(call check_protected_branch) $(call check_pending_pulls) + @$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG))) + @$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION))))) + @$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS))) + @$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS))) + @$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS))) @$(eval MINOR := $(shell echo $$(($(MINOR)+1)))) @$(eval PATCH := 0) $(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH)) @@ -102,6 +117,11 @@ minor: ## to bump minor version (semver) major: ## to bump major version (semver) $(call check_protected_branch) $(call check_pending_pulls) + @$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG))) + @$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION))))) + @$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS))) + @$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS))) + @$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS))) $(eval MAJOR := $(shell echo $$(($(MAJOR)+1)))) $(eval MINOR := 0) $(eval PATCH := 0) diff --git a/webapp/src/components/link_tooltip/link_tooltip.jsx b/webapp/src/components/link_tooltip/link_tooltip.jsx index bc4bf0019..5134e10c1 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.jsx @@ -1,19 +1,19 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, { useEffect, useMemo, useState } from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import PropTypes from 'prop-types'; import './tooltip.css'; -import { GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon } from '@primer/octicons-react'; +import {GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon} from '@primer/octicons-react'; import ReactMarkdown from 'react-markdown'; import Client from '@/client'; -import { getLabelFontColor, hexToRGB } from '../../utils/styles'; +import {getLabelFontColor, hexToRGB} from '../../utils/styles'; const maxTicketDescriptionLength = 160; -export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => { +export const LinkTooltip = ({href, connected, show, theme, enterpriseURL}) => { const [data, setData] = useState(null); useEffect(() => { const initData = async () => { @@ -37,12 +37,12 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => let res; switch (type) { - case 'issues': - res = await Client.getIssue(owner, repo, number); - break; - case 'pull': - res = await Client.getPullRequest(owner, repo, number); - break; + case 'issues': + res = await Client.getIssue(owner, repo, number); + break; + case 'pull': + res = await Client.getPullRequest(owner, repo, number); + break; } if (res) { res.owner = owner; @@ -64,6 +64,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => if (!data?.user?.login) { return null; } + // Immediately map the html_url value when present (which should work for both Enterprise and Cloud) if (data.user.html_url) { return data.user.html_url; @@ -88,32 +89,32 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => let icon; let color; switch (data.type) { - case 'pull': - icon = ; - - color = '#28a745'; - if (data.state === 'closed') { - if (data.merged) { - color = '#6f42c1'; - icon = ; - } else { - color = '#cb2431'; - } + case 'pull': + icon = ; + + color = '#28a745'; + if (data.state === 'closed') { + if (data.merged) { + color = '#6f42c1'; + icon = ; + } else { + color = '#cb2431'; } + } - break; - case 'issues': - color = data.state === 'open' ? '#28a745' : '#cb2431'; + break; + case 'issues': + color = data.state === 'open' ? '#28a745' : '#cb2431'; - if (data.state === 'open') { - icon = ; - } else { - icon = ; - } - break; + if (data.state === 'open') { + icon = ; + } else { + icon = ; + } + break; } return ( - + {icon} ); @@ -135,10 +136,10 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
- + {data.repo} {' on '} @@ -156,7 +157,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => href={href} target='_blank' rel='noopener noreferrer' - style={{ color: theme.centerChannelColor }} + style={{color: theme.centerChannelColor}} >
{data.title}
{'#' + data.number} @@ -202,7 +203,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => key={idx} className='label mr-1' title={label.description} - style={{ backgroundColor: '#' + label.color, color: getLabelFontColor(label.color) }} + style={{backgroundColor: '#' + label.color, color: getLabelFontColor(label.color)}} > {label.name}
diff --git a/webapp/src/components/link_tooltip/link_tooltip.test.jsx b/webapp/src/components/link_tooltip/link_tooltip.test.jsx index 0fa4f59ea..42f2bb3b2 100644 --- a/webapp/src/components/link_tooltip/link_tooltip.test.jsx +++ b/webapp/src/components/link_tooltip/link_tooltip.test.jsx @@ -1,16 +1,16 @@ import React from 'react'; -import { mount } from 'enzyme'; +import {mount} from 'enzyme'; import Client from '@/client'; -import { LinkTooltip } from './link_tooltip'; +import {LinkTooltip} from './link_tooltip'; jest.mock('@/client', () => ({ getIssue: jest.fn(), getPullRequest: jest.fn(), })); -jest.mock('react-markdown', () => () =>
); +jest.mock('react-markdown', () => () =>
); describe('LinkTooltip', () => { const baseProps = { @@ -37,7 +37,7 @@ describe('LinkTooltip', () => { }); test('should fetch issue for github.com link', () => { - wrapper = mount(); + wrapper = mount(); expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '1'); }); @@ -46,7 +46,7 @@ describe('LinkTooltip', () => { ...baseProps, href: 'https://github.com/mattermost/mattermost-plugin-github/pull/2', }; - wrapper = mount(); + wrapper = mount(); expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '2'); }); @@ -56,7 +56,7 @@ describe('LinkTooltip', () => { href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3', enterpriseURL: 'https://github.example.com', }; - wrapper = mount(); + wrapper = mount(); expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '3'); }); @@ -66,7 +66,7 @@ describe('LinkTooltip', () => { href: 'https://github.example.com/mattermost/mattermost-plugin-github/pull/4', enterpriseURL: 'https://github.example.com', }; - wrapper = mount(); + wrapper = mount(); expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '4'); }); @@ -76,7 +76,7 @@ describe('LinkTooltip', () => { href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/5', enterpriseURL: 'https://github.example.com/', }; - wrapper = mount(); + wrapper = mount(); expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '5'); }); @@ -86,7 +86,7 @@ describe('LinkTooltip', () => { href: 'https://other-github.com/mattermost/mattermost-plugin-github/issues/6', enterpriseURL: 'https://github.example.com', }; - wrapper = mount(); + wrapper = mount(); expect(Client.getIssue).not.toHaveBeenCalled(); }); @@ -104,7 +104,7 @@ describe('LinkTooltip', () => { created_at: '2023-01-01T00:00:00Z', }); - wrapper = mount(); + wrapper = mount(); await new Promise((resolve) => setTimeout(resolve, 0)); wrapper.update(); @@ -132,7 +132,7 @@ describe('LinkTooltip', () => { href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3', enterpriseURL: 'https://github.example.com', }; - wrapper = mount(); + wrapper = mount(); await new Promise((resolve) => setTimeout(resolve, 0)); wrapper.update(); @@ -160,7 +160,7 @@ describe('LinkTooltip', () => { href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3', enterpriseURL: 'https://github.example.com/', }; - wrapper = mount(); + wrapper = mount(); await new Promise((resolve) => setTimeout(resolve, 0)); wrapper.update(); @@ -182,7 +182,7 @@ describe('LinkTooltip', () => { created_at: '2023-01-01T00:00:00Z', }); - wrapper = mount(); + wrapper = mount(); await new Promise((resolve) => setTimeout(resolve, 0)); wrapper.update();