Skip to content

Commit

Permalink
feat(http): homedir
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
johnandersen777 committed Nov 29, 2024
1 parent 6502149 commit e34315e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "gitatp"
version = "0.1.2"
version = "0.1.3"
description = "Git over ATProto"
long_description = "# Git over ATProto"
long_description_content_type = "text/markdown"
Expand Down
26 changes: 19 additions & 7 deletions src/gitatp/git_http_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
allowed_hash_algs = ['sha256', hash_alg, 'sha512']

# TODO DEBUG REMOVE
os.environ["HOME"] = str(Path(__file__).parent.resolve())
# os.environ["HOME"] = str(Path(__file__).parent.resolve())

parser = argparse.ArgumentParser(prog='atproto-git', usage='%(prog)s [options]')
parser.add_argument('--repos-directory', dest="repos_directory", help='directory for local copies of git repos')
Expand All @@ -40,14 +40,26 @@
config = configparser.ConfigParser()
config.read(str(Path("~", ".gitconfig").expanduser()))

atproto_handle = config["user"]["atproto"]
try:
atproto_handle = config["user"]["atproto"]
except Exception as e:
raise Exception(f"You must run: $ git config --global user.atproto $USER.atproto-pds.fqdn.example.com") from e
try:
atproto_email = config["user"]["email"]
except Exception as e:
raise Exception(f"You must run: $ git config --global user.atproto $USER.atproto-pds.fqdn.example.com") from e

atproto_handle_username = atproto_handle.split(".")[0]
atproto_base_url = "https://" + ".".join(atproto_handle.split(".")[1:])
atproto_email = config["user"]["email"]
atproto_password = keyring.get_password(
atproto_email,
".".join(["password", atproto_handle]),
)
keyring_atproto_password = ".".join(["password", atproto_handle])

try:
atproto_password = keyring.get_password(
atproto_email,
keyring_atproto_password,
)
except Exception as e:
raise Exception(f"You must run: $ python -m keyring set {atproto_email} {keyring_atproto_password}") from e

class CacheATProtoBlob(BaseModel):
hash_alg: str
Expand Down
34 changes: 34 additions & 0 deletions src/gitatp/update_profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { BskyAgent } from '@atproto/api'
/*
import { PGlite } from "@electric-sql/pglite";
import { live } from '@electric-sql/pglite/live';
import { lo } from '@electric-sql/pglite/contrib/lo';
const pg = new PGlite(
"./my-pgdata",
{
extensions: { live, lo }
},
);
await db.query("select 'Hello world' as message;")
*/

const agent = new BskyAgent({
service: Deno.env.get("ATPROTO_BASE_URL"),
})
await agent.login({
identifier: Deno.env.get("ATPROTO_HANDLE"),
password: Deno.env.get("ATPROTO_PASSWORD"),
})

await agent.upsertProfile(existingProfile => {
const existing = existingProfile ?? {}

existing.pinnedPost = {
"uri": Deno.env.get("ATPROTO_PINNED_POST_URI"),
"cid": Deno.env.get("ATPROTO_PINNED_POST_CID"),
}

return existing
})

0 comments on commit e34315e

Please sign in to comment.