-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shellcheck and shfmt on bash scripts #204
Open
KaushikMalapati
wants to merge
21
commits into
pcdshub:master
Choose a base branch
from
KaushikMalapati:bash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6ce2736
MNT: Shellchecking bash scripts
273ecd5
Tentatively adding shellfmt to precommit
6a5b329
Update scripts/takepeds
KaushikMalapati 57a61f8
MNT: Shellchecking bash scripts
f32309b
Tentatively adding shellfmt to precommit
182778a
Update scripts/takepeds
KaushikMalapati 0e3520b
Merging README.md
57616f7
Exporting potentially unused variables, ignoring cd warning
1b284de
Running shfmt on everything
23fef11
Replacing reg with cds
3dba6ea
Accidentally added a c
484b89f
Revert afs-remote-fix link, deleting some exports and unused variable…
556db88
Using :upper: and :lower: instead of A-Z and a-z for SC2018 and SC2019
bcb408c
Manually disabling SC2164 lines and updating global disables
f6877c3
Adjusting some print statements
9417a8a
Removing comment
d199146
Checking exit code directly
35bfa4a
Fixing misspelling
01ee672
Reverting /cds/group to /reg/g in sed replacement
2a429fb
Checking for nonzero exit code, not command success
6f4d487
Adjusting printed output and putting space in parameter expansion
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
disable=SC1091 # allow sourcing files that can't immediately be found (pcds_conda) | ||
disable=SC1091,SC2018,SC2019,SC2164 # allow sourcing files that can't immediately be found (pcds_conda), disable warnings about supporting accents and foreign languages, disable cd warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
Copyright (c) 2018, The Board of Trustees of the Leland Stanford Junior | ||
University, through SLAC National Accelerator Laboratory (subject to receipt | ||
of any required approvals from the U.S. Dept. of Energy). All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
Copyright (c) 2018, The Board of Trustees of the Leland Stanford Junior | ||
University, through SLAC National Accelerator Laboratory (subject to receipt | ||
of any required approvals from the U.S. Dept. of Energy). All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
(1) Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
(2) Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
(1) Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
(3) Neither the name of the Leland Stanford Junior University, SLAC National | ||
Accelerator Laboratory, U.S. Dept. of Energy nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
(2) Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, THE UNITED STATES GOVERNMENT, | ||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
(3) Neither the name of the Leland Stanford Junior University, SLAC National | ||
Accelerator Laboratory, U.S. Dept. of Energy nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, THE UNITED STATES GOVERNMENT, | ||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
OF SUCH DAMAGE. | ||
|
||
You are under no obligation whatsoever to provide any bug fixes, patches, or | ||
upgrades to the features, functionality or performance of the source code | ||
("Enhancements") to anyone; however, if you choose to make your Enhancements | ||
available either publicly, or directly to SLAC National Accelerator Laboratory, | ||
without imposing a separate written license agreement for such Enhancements, | ||
then you hereby grant the following license: a non-exclusive, royalty-free | ||
You are under no obligation whatsoever to provide any bug fixes, patches, or | ||
upgrades to the features, functionality or performance of the source code | ||
("Enhancements") to anyone; however, if you choose to make your Enhancements | ||
available either publicly, or directly to SLAC National Accelerator Laboratory, | ||
without imposing a separate written license agreement for such Enhancements, | ||
then you hereby grant the following license: a non-exclusive, royalty-free | ||
perpetual license to install, use, modify, prepare derivative works, incorporate | ||
into other computer software, distribute, and sublicense such Enhancements or | ||
into other computer software, distribute, and sublicense such Enhancements or | ||
derivative works thereof, in binary and source code form. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,3 @@ au FileType python | |
\ autoindent | ||
\ fileformat=unix | ||
\ encoding=utf-8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KaushikMalapati marked this conversation as resolved.
Show resolved
Hide resolved
|
This file was deleted.
Oops, something went wrong.
KaushikMalapati marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/python3 | ||
""" | ||
afs-remote-fix is a script for repointing your afs git remotes towards github. | ||
|
||
It will check if you're currently in a git ioc repo with an afs remote as your origin, | ||
switching it to your fork and adding an upstream remote to pcdshub. | ||
|
||
An afs remote is a git remote with a path that looks something like this: | ||
/afs/slac.stanford.edu/g/cd/swe/git/repos/package/epics/ioc/common/ims.git | ||
|
||
If this path is your origin, after running the script you will instead have: | ||
|
||
origin git@github.com:your-username/ioc-common-ims.git | ||
upstream git@github.com:pcdshub/ioc-common-ims.git | ||
|
||
If the origin is not an afs path, this script will exit without taking any action. | ||
|
||
The script will prompt you for your github username, which is not necessarily | ||
the same as your slac username. | ||
""" | ||
|
||
import subprocess | ||
|
||
|
||
def main() -> int: | ||
origin = subprocess.check_output( | ||
["git", "remote", "get-url", "origin"], universal_newlines=True | ||
).strip() | ||
if not origin.startswith("/afs/"): | ||
print(f"Your origin {origin} is not an afs repo.") | ||
return 1 | ||
elif "/ioc/" not in origin: | ||
print(f"Your origin {origin} is not an ioc repo.") | ||
return 1 | ||
_, ioc_path = origin.split("/ioc/") | ||
repo_name = f"ioc-{ioc_path.replace('/', '-', 1)}" | ||
username = input("Please input your github username:\n") | ||
new_origin = f"git@github.com:{username}/{repo_name}" | ||
new_upstream = f"git@github.com:pcdshub/{repo_name}" | ||
print("\nPlanning to set:") | ||
print(f"origin to {new_origin}") | ||
print(f"upstream to {new_upstream}") | ||
confirm = input("Confirm? y/n\n") | ||
if not confirm.lower().startswith("y"): | ||
return 1 | ||
subprocess.run(["git", "remote", "set-url", "origin", new_origin]) | ||
subprocess.run(["git", "remote", "add", "upstream", new_upstream]) | ||
subprocess.run(["git", "remote", "-v"]) | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
exit(main()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we deprecate this in favor of our shared dotfiles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should, or we could at least include instructions in here for updating to the full shared dotfiles. This is a reasonable follow-up issue.