Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit ad878c8

Browse files
committed
Fixed company in mkpr.sh, mkrepo.sh, paste.sh
1 parent 2c45f28 commit ad878c8

4 files changed

Lines changed: 124 additions & 20 deletions

File tree

TODO.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# TODO for configurable-company
2+
3+
- [ ] `checkout.sh`: Necessary only if using submodules
4+
- [ ] `clean-checkout.sh`: Could be optimized if not using submodules
5+
- [ ] `clone.sh`: Necessary only if using Git LFS
6+
- [ ] `copr.sh`: Necessary only if using GitHub Enterprise
7+
- [ ] `enable-public-push.sh`: Necessary only if working additionally with github.com
8+
- [ ] `help.sh`: Help should be generated out of single commands.
9+
Maybe some commands will be skipped for a certain company
10+
- [ ] `install-helper.ps1`: to be analyzed
11+
- [ ] `install.bat`: to be analyzed
12+
- [ ] `install.sh`: to be analyzed
13+
- [ ] `mkpr.sh`: Necessary only if using GitHub Enterprise
14+
- [x] Variables needs to be renamed (`GITHUB_*` => `GHE_*`)
15+
- [x] `adsk` needs to be replaced with `$KIT_ID`
16+
- [ ] slug specific code must be isolated
17+
- [ ] `mkrepo.sh`: Necessary only if using GitHub Enterprise
18+
- [x] Variables needs to be renamed (`GITHUB_*` => `GHE_*`)
19+
- [ ] `paste.sh`: Necessary only if using GitHub Enterprise
20+
- [x] Variables needs to be renamed (`GITHUB_*` => `GHE_*`)
21+
- [ ] `pull.sh`: Necessary only if using submodules
22+
- [ ] `setup.sh`: Split different tasks into separate scripts for better tailoring
23+
- [x] `show-deleted.sh`: OK
24+
- [ ] `teardown.sh`: Contains string << YOUR GITHUB SERVER >>. Should be replaced with
25+
`$GHE_SERVER`
26+
- [x] `version.sh`: OK
27+
28+
## Features
29+
- Submodules
30+
- Git LFS
31+
- GitHub Enterprise
32+
33+
## Platforms
34+
- Windows
35+
- Mac OSx
36+
- Linux
37+
38+
## Use Cases
39+
40+
### Company adds company specific script
41+
There shall be a way to store company specific scripts. These scripts shall be
42+
included in help, ...
43+
44+
### Company patches generic script
45+
There shall be a way to patch existing generic scripts for a company.
46+
47+
### Company deletes generic script
48+
There shall be a way to delete generic scripts for a company, because they might
49+
be dangerous or the use case is not covered in that company.
50+
51+
### Company updates generic scripts
52+
When updating the generic scripts to a new version then the added, patched and
53+
deleted scripts shall be kept. It is the repsonsiblity of the company to check
54+
if the company adaptations are still valid.
55+
56+
### User specific scripts
57+
If users write own scripts they should not be overwritten when an update is done.
58+
59+
## Design Ideas
60+
61+
### Company specific folder
62+
On top-level there shall be a new folder with the $KIT_ID name, e.g. adsk which
63+
contains company specific scripts. When this folder only exists on a branch
64+
`adsk-production` then a merge would never have a conflict, because this folder
65+
only exists in that branch and not on the `master` branch.
66+
67+
Proposed directory structure:
68+
```
69+
lib => generic scripts, so move all scripts here
70+
lib/lnx => generic linux specific scripts
71+
lib/osx => generic OSx specific scripts
72+
lib/win => generic windows specific scripts
73+
lib/other => generic other specific scripts
74+
<company> => company OS independent scripts
75+
<company>/lnx => company linux specific scripts
76+
<company>/osx => company osx specific scripts
77+
<company>/win => company windows specific scripts
78+
<company>/other => company windows specific scripts
79+
```
80+
81+
### Company adds company specific script
82+
Put the script in `<company>` folder.
83+
To get this working the `config.include` must be changed:
84+
```shell
85+
...
86+
elif [ -e \"$KIT_PATH/<company>/$COMMAND.sh\" ]; then
87+
bash \"$KIT_PATH/$COMMAND.sh\" $@; \
88+
...
89+
```
90+
### Company Adaptations
91+
#### Alternative A: disallow features in `enterprise.constants`
92+
- Some features (= scripts) might be dangerous
93+
- Based on values in `enterprise.constants` features (= scripts) shall be enabled
94+
/ disabled.
95+
- Therefore each script must check if the feature is allowed to avoid direct calls
96+
- In `config.include` there should be a check if the featrue is allowed before
97+
calling it
98+
99+
#### Alternative B: setup.sh shall run a company specific setup.sh
100+
In `setup.sh` at the end run `$KIT_ID/setup.sh` (if it exists) which contains
101+
company specific setup, e.g. scripts to be added, patched, or removed:
102+
- Added scripts: copy from a company folder to the main folder
103+
- Patched scripts: copy and overwrite from a company folder to the main folder
104+
- Removed scripts: delete from the main folder

mkpr.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ KIT_PATH=$(dirname "$0")
3333
. "$KIT_PATH/lib/setup_helpers.sh"
3434

3535
set +e
36-
BASE_BRANCH=$(git config 'adsk.pr-base-default')
36+
BASE_BRANCH=$(git config '$KIT_ID.pr-base-default')
3737
set -e
3838
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
39-
for BRANCH in $(git config --get-regexp 'adsk\.pr-base-branch-' | sed 's/.* //'); do
40-
BRANCH=${BRANCH#adsk.pr-base-branch-}
39+
for BRANCH in $(git config --get-regexp '$KIT_ID\.pr-base-branch-' | sed 's/.* //'); do
40+
BRANCH=${BRANCH#$KIT_ID.pr-base-branch-}
4141
shopt -s nocasematch
4242
case "$CURRENT_BRANCH" in
4343
*$BRANCH*)
@@ -50,7 +50,7 @@ done
5050

5151
if [ -z "$BASE_BRANCH" ]
5252
then
53-
error_exit "No base branch found.\n Please configure your default Pull Request base with:\n git config --local adsk.pr-base-default YourBaseBranch"
53+
error_exit "No base branch found.\n Please configure your default Pull Request base with:\n git config --local $KIT_ID.pr-base-default YourBaseBranch"
5454
else
5555
print_success "Pull Request base: $BASE_BRANCH"
5656
fi
@@ -63,8 +63,8 @@ fi
6363

6464
git push --set-upstream $REMOTE "$CURRENT_BRANCH"
6565

66-
USER=$(git config adsk.github.account)
67-
PASSWORD="$(get_credentials $GITHUB_SERVER $USER)"
66+
USER=$(git config $KIT_ID.github.account)
67+
PASSWORD="$(get_credentials $GHE_SERVER $USER)"
6868
SLUG_REGEX='/autodesk\.com[:\/]([^\/]+\/[^\/\.]+)/ && print "$1\n"'
6969
SLUG=$(git config --get remote.$REMOTE.url | perl -ne "$SLUG_REGEX")
7070

@@ -81,7 +81,7 @@ fi
8181

8282
PR_URL=$(curl $CURL_RETRY_OPTIONS --silent --fail --user "$USER:$PASSWORD" -X POST \
8383
--data "{\"title\": \"$CURRENT_BRANCH\", \"head\": \"$CURRENT_BRANCH\", \"base\": \"$BASE_BRANCH\"}" \
84-
"https://$GITHUB_SERVER/api/v3/repos/$SLUG/pulls" \
84+
"https://$GHE_SERVER/api/v3/repos/$SLUG/pulls" \
8585
| perl -ne 'print "$1\n" if m%^\s*"html_url":\s*"(.*\/pull\/[0-9]+)"[,]?$%i' \
8686
)
8787

mkrepo.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ KIT_PATH=$(dirname "$0")
1414
. "$KIT_PATH/enterprise.constants"
1515
. "$KIT_PATH/lib/setup_helpers.sh"
1616

17-
ADS_USER=$(git config --global adsk.github.account)
18-
[ -z "$ADS_USER" ] && error_exit 'Username must not be empty!'
17+
GHE_USER=$(git config --global $KIT_ID.github.account)
18+
[ -z "$GHE_USER" ] && error_exit 'Username must not be empty!'
1919

20-
SERVER=$(git config --global adsk.github.server)
20+
SERVER=$(git config --global $KIT_ID.github.server)
2121
[ -z "$SERVER" ] && error_exit 'Server must not be empty!'
2222

23-
TOKEN="$(get_credentials $SERVER $ADS_USER)"
23+
TOKEN="$(get_credentials $SERVER $GHE_USER)"
2424
[ -z "$TOKEN" ] && echo "Missing GitHub token" && exit 1
2525

2626
URL="https://$SERVER/api/v3/user/repos"
@@ -39,4 +39,4 @@ then
3939
exit $STATUS
4040
fi
4141

42-
echo "repo 'https://$SERVER/$ADS_USER/$REPO' created!"
42+
echo "repo 'https://$SERVER/$GHE_USER/$REPO' created!"

paste.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ KIT_PATH=$(dirname "$0")
1010
. "$KIT_PATH/enterprise.constants"
1111
. "$KIT_PATH/lib/setup_helpers.sh"
1212

13-
ADS_USER=$(git config --global adsk.github.account)
14-
SERVER=$(git config --global adsk.github.server)
13+
GHE_USER=$(git config --global $KIT_ID.github.account)
14+
SERVER=$(git config --global $KIT_ID.github.server)
1515

16-
if [ -z "$ADS_USER" ]; then
16+
if [ -z "$GHE_USER" ]; then
1717
error_exit 'Username must not be empty!'
1818
fi
1919

2020
if [ -z "$SERVER" ]; then
2121
error_exit 'Server must not be empty!'
2222
fi
2323

24-
ADS_PASSWORD_OR_TOKEN="$(get_credentials $SERVER $ADS_USER)"
24+
GHE_PASSWORD_OR_TOKEN="$(get_credentials $SERVER $GHE_USER)"
2525

26-
[ -z "$ADS_PASSWORD_OR_TOKEN" ] && echo "Could not obtain password or token" && exit 1
27-
[ "$ADS_PASSWORD_OR_TOKEN" = "" ] && echo "Blank password or token" && exit 1
26+
[ -z "$GHE_PASSWORD_OR_TOKEN" ] && echo "Could not obtain password or token" && exit 1
27+
[ "$GHE_PASSWORD_OR_TOKEN" = "" ] && echo "Blank password or token" && exit 1
2828

2929
perl $KIT_PATH/lib/paste.pl \
30-
--user $ADS_USER \
31-
--token $ADS_PASSWORD_OR_TOKEN \
30+
--user $GHE_USER \
31+
--token $GHE_PASSWORD_OR_TOKEN \
3232
--server $SERVER \
3333
$@

0 commit comments

Comments
 (0)