Skip to content

Commit 909e0b0

Browse files
MM-67176 Propagating fix for version bump when releasing new versions (#957)
- Fixing linter issues that were merged
1 parent ff93bfa commit 909e0b0

File tree

3 files changed

+70
-49
lines changed

3 files changed

+70
-49
lines changed

Makefile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ endif
4343
# Used for semver bumping
4444
PROTECTED_BRANCH := master
4545
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`)
46-
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags)
46+
CURRENT_VERSION := $(strip $(shell git describe --abbrev=0 --tags))
47+
LATEST_RELEASE_TAG_RAW := $(shell git tag -l "v*" --sort=-v:refname | grep -v '\-rc' | head -n 1 || true)
48+
LATEST_RELEASE_TAG := $(strip $(LATEST_RELEASE_TAG_RAW))
49+
ifeq ($(LATEST_RELEASE_TAG),)
50+
LATEST_RELEASE_TAG := $(CURRENT_VERSION)
51+
endif
4752
VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION))))
4853
MAJOR := $(word 1,$(VERSION_PARTS))
4954
MINOR := $(word 2,$(VERSION_PARTS))
@@ -81,6 +86,11 @@ endef
8186
patch: ## to bump patch version (semver)
8287
$(call check_protected_branch)
8388
$(call check_pending_pulls)
89+
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
90+
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
91+
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
92+
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
93+
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
8494
@$(eval PATCH := $(shell echo $$(($(PATCH)+1))))
8595
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
8696
@echo Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)
@@ -91,6 +101,11 @@ patch: ## to bump patch version (semver)
91101
minor: ## to bump minor version (semver)
92102
$(call check_protected_branch)
93103
$(call check_pending_pulls)
104+
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
105+
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
106+
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
107+
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
108+
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
94109
@$(eval MINOR := $(shell echo $$(($(MINOR)+1))))
95110
@$(eval PATCH := 0)
96111
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
@@ -102,6 +117,11 @@ minor: ## to bump minor version (semver)
102117
major: ## to bump major version (semver)
103118
$(call check_protected_branch)
104119
$(call check_pending_pulls)
120+
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
121+
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
122+
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
123+
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
124+
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
105125
$(eval MAJOR := $(shell echo $$(($(MAJOR)+1))))
106126
$(eval MINOR := 0)
107127
$(eval PATCH := 0)

webapp/src/components/link_tooltip/link_tooltip.jsx

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
22
// See LICENSE.txt for license information.
33

4-
import React, { useEffect, useMemo, useState } from 'react';
4+
import React, {useEffect, useMemo, useState} from 'react';
55
import PropTypes from 'prop-types';
66
import './tooltip.css';
7-
import { GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon } from '@primer/octicons-react';
7+
import {GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon} from '@primer/octicons-react';
88
import ReactMarkdown from 'react-markdown';
99

1010
import Client from '@/client';
1111

12-
import { getLabelFontColor, hexToRGB } from '../../utils/styles';
12+
import {getLabelFontColor, hexToRGB} from '../../utils/styles';
1313

1414
const maxTicketDescriptionLength = 160;
1515

16-
export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => {
16+
export const LinkTooltip = ({href, connected, show, theme, enterpriseURL}) => {
1717
const [data, setData] = useState(null);
1818
useEffect(() => {
1919
const initData = async () => {
@@ -37,12 +37,12 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
3737

3838
let res;
3939
switch (type) {
40-
case 'issues':
41-
res = await Client.getIssue(owner, repo, number);
42-
break;
43-
case 'pull':
44-
res = await Client.getPullRequest(owner, repo, number);
45-
break;
40+
case 'issues':
41+
res = await Client.getIssue(owner, repo, number);
42+
break;
43+
case 'pull':
44+
res = await Client.getPullRequest(owner, repo, number);
45+
break;
4646
}
4747
if (res) {
4848
res.owner = owner;
@@ -64,6 +64,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
6464
if (!data?.user?.login) {
6565
return null;
6666
}
67+
6768
// Immediately map the html_url value when present (which should work for both Enterprise and Cloud)
6869
if (data.user.html_url) {
6970
return data.user.html_url;
@@ -88,32 +89,32 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
8889
let icon;
8990
let color;
9091
switch (data.type) {
91-
case 'pull':
92-
icon = <GitPullRequestIcon {...iconProps} />;
93-
94-
color = '#28a745';
95-
if (data.state === 'closed') {
96-
if (data.merged) {
97-
color = '#6f42c1';
98-
icon = <GitMergeIcon {...iconProps} />;
99-
} else {
100-
color = '#cb2431';
101-
}
92+
case 'pull':
93+
icon = <GitPullRequestIcon {...iconProps}/>;
94+
95+
color = '#28a745';
96+
if (data.state === 'closed') {
97+
if (data.merged) {
98+
color = '#6f42c1';
99+
icon = <GitMergeIcon {...iconProps}/>;
100+
} else {
101+
color = '#cb2431';
102102
}
103+
}
103104

104-
break;
105-
case 'issues':
106-
color = data.state === 'open' ? '#28a745' : '#cb2431';
105+
break;
106+
case 'issues':
107+
color = data.state === 'open' ? '#28a745' : '#cb2431';
107108

108-
if (data.state === 'open') {
109-
icon = <IssueOpenedIcon {...iconProps} />;
110-
} else {
111-
icon = <IssueClosedIcon {...iconProps} />;
112-
}
113-
break;
109+
if (data.state === 'open') {
110+
icon = <IssueOpenedIcon {...iconProps}/>;
111+
} else {
112+
icon = <IssueClosedIcon {...iconProps}/>;
113+
}
114+
break;
114115
}
115116
return (
116-
<span style={{ color }}>
117+
<span style={{color}}>
117118
{icon}
118119
</span>
119120
);
@@ -135,10 +136,10 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
135136
<div className='github-tooltip'>
136137
<div
137138
className='github-tooltip box github-tooltip--large github-tooltip--bottom-left p-4'
138-
style={{ backgroundColor: theme.centerChannelBg, border: `1px solid ${hexToRGB(theme.centerChannelColor, '0.16')}` }}
139+
style={{backgroundColor: theme.centerChannelBg, border: `1px solid ${hexToRGB(theme.centerChannelColor, '0.16')}`}}
139140
>
140141
<div className='header mb-1'>
141-
<span style={{ color: theme.centerChannelColor }}>
142+
<span style={{color: theme.centerChannelColor}}>
142143
{data.repo}
143144
</span>
144145
{' on '}
@@ -156,7 +157,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
156157
href={href}
157158
target='_blank'
158159
rel='noopener noreferrer'
159-
style={{ color: theme.centerChannelColor }}
160+
style={{color: theme.centerChannelColor}}
160161
>
161162
<h5 className='mr-1'>{data.title}</h5>
162163
<span>{'#' + data.number}</span>
@@ -202,7 +203,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
202203
key={idx}
203204
className='label mr-1'
204205
title={label.description}
205-
style={{ backgroundColor: '#' + label.color, color: getLabelFontColor(label.color) }}
206+
style={{backgroundColor: '#' + label.color, color: getLabelFontColor(label.color)}}
206207
>
207208
<span>{label.name}</span>
208209
</span>

webapp/src/components/link_tooltip/link_tooltip.test.jsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React from 'react';
2-
import { mount } from 'enzyme';
2+
import {mount} from 'enzyme';
33

44
import Client from '@/client';
55

6-
import { LinkTooltip } from './link_tooltip';
6+
import {LinkTooltip} from './link_tooltip';
77

88
jest.mock('@/client', () => ({
99
getIssue: jest.fn(),
1010
getPullRequest: jest.fn(),
1111
}));
1212

13-
jest.mock('react-markdown', () => () => <div />);
13+
jest.mock('react-markdown', () => () => <div/>);
1414

1515
describe('LinkTooltip', () => {
1616
const baseProps = {
@@ -37,7 +37,7 @@ describe('LinkTooltip', () => {
3737
});
3838

3939
test('should fetch issue for github.com link', () => {
40-
wrapper = mount(<LinkTooltip {...baseProps} />);
40+
wrapper = mount(<LinkTooltip {...baseProps}/>);
4141
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '1');
4242
});
4343

@@ -46,7 +46,7 @@ describe('LinkTooltip', () => {
4646
...baseProps,
4747
href: 'https://github.com/mattermost/mattermost-plugin-github/pull/2',
4848
};
49-
wrapper = mount(<LinkTooltip {...props} />);
49+
wrapper = mount(<LinkTooltip {...props}/>);
5050
expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '2');
5151
});
5252

@@ -56,7 +56,7 @@ describe('LinkTooltip', () => {
5656
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
5757
enterpriseURL: 'https://github.example.com',
5858
};
59-
wrapper = mount(<LinkTooltip {...props} />);
59+
wrapper = mount(<LinkTooltip {...props}/>);
6060
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '3');
6161
});
6262

@@ -66,7 +66,7 @@ describe('LinkTooltip', () => {
6666
href: 'https://github.example.com/mattermost/mattermost-plugin-github/pull/4',
6767
enterpriseURL: 'https://github.example.com',
6868
};
69-
wrapper = mount(<LinkTooltip {...props} />);
69+
wrapper = mount(<LinkTooltip {...props}/>);
7070
expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '4');
7171
});
7272

@@ -76,7 +76,7 @@ describe('LinkTooltip', () => {
7676
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/5',
7777
enterpriseURL: 'https://github.example.com/',
7878
};
79-
wrapper = mount(<LinkTooltip {...props} />);
79+
wrapper = mount(<LinkTooltip {...props}/>);
8080
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '5');
8181
});
8282

@@ -86,7 +86,7 @@ describe('LinkTooltip', () => {
8686
href: 'https://other-github.com/mattermost/mattermost-plugin-github/issues/6',
8787
enterpriseURL: 'https://github.example.com',
8888
};
89-
wrapper = mount(<LinkTooltip {...props} />);
89+
wrapper = mount(<LinkTooltip {...props}/>);
9090
expect(Client.getIssue).not.toHaveBeenCalled();
9191
});
9292

@@ -104,7 +104,7 @@ describe('LinkTooltip', () => {
104104
created_at: '2023-01-01T00:00:00Z',
105105
});
106106

107-
wrapper = mount(<LinkTooltip {...baseProps} />);
107+
wrapper = mount(<LinkTooltip {...baseProps}/>);
108108

109109
await new Promise((resolve) => setTimeout(resolve, 0));
110110
wrapper.update();
@@ -132,7 +132,7 @@ describe('LinkTooltip', () => {
132132
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
133133
enterpriseURL: 'https://github.example.com',
134134
};
135-
wrapper = mount(<LinkTooltip {...props} />);
135+
wrapper = mount(<LinkTooltip {...props}/>);
136136

137137
await new Promise((resolve) => setTimeout(resolve, 0));
138138
wrapper.update();
@@ -160,7 +160,7 @@ describe('LinkTooltip', () => {
160160
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
161161
enterpriseURL: 'https://github.example.com/',
162162
};
163-
wrapper = mount(<LinkTooltip {...props} />);
163+
wrapper = mount(<LinkTooltip {...props}/>);
164164

165165
await new Promise((resolve) => setTimeout(resolve, 0));
166166
wrapper.update();
@@ -182,7 +182,7 @@ describe('LinkTooltip', () => {
182182
created_at: '2023-01-01T00:00:00Z',
183183
});
184184

185-
wrapper = mount(<LinkTooltip {...baseProps} />);
185+
wrapper = mount(<LinkTooltip {...baseProps}/>);
186186

187187
await new Promise((resolve) => setTimeout(resolve, 0));
188188
wrapper.update();

0 commit comments

Comments
 (0)